本文实例为大家分享了bootstrap Table的操作代码,供大家参考,具体内容如下
function HQCreatTable(ob) { var option = { cache: false,//是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*) scrollX: true, scrollY:true, striped: true, //使表格带有条纹 //是否显示行间隔色 sidePagination: "client",//分页方式:client客户端分页,server服务端分页(*) pagination: true, //在表格底部显示分页工具栏 pageNumber: 1, //初始化加载第一页,默认第一页 pageSize: 10, pageList: [ 10,15],//可供选择的每页的行数(*) showColumns: false,//是否显示所有的列 sortable: true, //是否启用排序 clickToSelect: true,//是否启用点击选中行 showRefresh: false, //显示刷新按钮 //search: false,//是否显示右上角的搜索框 //toolbar: '#toolbar', //工具按钮用哪个容器 uniqueId: "ID", //每一行的唯一标识,一般为主键列 undefinedText: "", toolbarAlign: 'left', exportDataType: "all", //basic', 'all', 'selected'. } if (ob.rowStyle) { option.rowStyle = ob.rowStyle;//行样式 是函数 } //排序 if (ob.sortOrder) { option.sortOrder = ob.sortOrder; } else { option.sortOrder = "desc"; } if (ob.sortName) { option.sortName = ob.sortName; } if (ob.showExport) { option.showExport = ob.showExport;//导出Excel } if (ob.showFooter) { option.showFooter = ob.showFooter;//是否显示统计页脚 } if (ob.searchAlign) { option.searchAlign = ob.searchAlign; } if (ob.num) { option.pageSize = ob.num;//每页的记录行数(*) } if (ob.data) { option.data = ob.data; } else { option.data = []; } if (ob.search) { option.search = ob.search; } if (ob.columns) { option.columns = ob.columns; } if (ob.onClickRow) { option.onClickRow = ob.onClickRow; } if (ob.onDblClickRow) { option.onDblClickRow = ob.onDblClickRow; } if (ob.onDblClickRow) { option.onDblClickRow = ob.onDblClickRow; } if (ob.onCheck) { option.onCheck = ob.onCheck; } if (ob.onAll) { option.onAll = ob.onAll; } if (ob.onLoadSuccess) { option.onLoadSuccess = ob.onLoadSuccess; } if (ob.toolbar) { option.toolbar = ob.toolbar; } if (ob.singleSelect || ob.singleSelect == false) { option.singleSelect = ob.singleSelect } else { option.singleSelect = true;//禁止多选 } if (ob.maintainSelected) { option.maintainSelected = ob.maintainSelected; } else { option.maintainSelected = false;//设置为 true 在点击分页按钮或搜索按钮时,将记住checkbox的选择项 } if (ob.detailView) { option.detailView = ob.detailView; } if (ob.onExpandRow) { option.onExpandRow = ob.onExpandRow; } if (ob.onEditableSave) { option.onEditableSave = ob.onEditableSave; } $(ob.id).bootstrapTable('destroy'); $(ob.id).bootstrapTable(option); if (ob.data) { $(ob.id).bootstrapTable('load', ob.data); } }
内容版权声明:除非注明,否则皆为本站原创文章。