bootstrap-table根本应用
bootstrap-table基本应用
参考资料:
http://bootstrap-table.wenzhixin.net.cn/zh-cn/documentation/
分页的话后台一定要接收这两个参数
参考资料:
http://bootstrap-table.wenzhixin.net.cn/zh-cn/documentation/
<table data-toggle="table" id="table" data-toolbar="#toolbar" data-single-select="true" data-click-to-select="true"> <thead> <tr class="info"> <th data-checkbox="true"></th> <th data-field="empid" data-visible="false">id</th> <th data-field="列字段,与后台查询出来的要对应">列说明</th> </tr> </thead> </table>
function initTable(url, tableId) { $table = $('#'+tableId); $table.bootstrapTable('destroy'); $table.bootstrapTable({ url: url, method: 'post', contentType: "application/x-www-form-urlencoded; charset=UTF-8", pagination: true, pageNumber: staticObj.pageNumber, pageSize: staticObj.pageSize, pageList: [10, 25, 50, 100], //分页方式:client客户端分页,server服务端分页(*) sidePagination: "server", /*默认值为 'limit' ,在默认情况下 传给服务端的参数为:offset,limit,sort 设置为 '' 在这种情况下传给服务器的参数为:pageSize,pageNumber*/ //queryParamsType: '', //查询参数,每次调用是会带上这个参数,可自定义。若设置此参数,则不能自动传offset和limit参数 /*queryParams: function(params) { //var subcompany = $('#subcompany option:selected').val(); return { //pageNumber: params.offset, //pageSize: params.limit //companyId:subcompany, }; },*/ /*data: data*/ }); }
分页的话后台一定要接收这两个参数
private Integer offset; private Integer limit;
@Action(value="findAll", results={@Result(name = "json" , type="json", params={"root","map"})}) public String findAll(){ List<EmployeeEntity> list = service.findAll(); map = new HashMap(); map.put("total",service.count()); //数据总数 map.put("rows",list); //分页后的数据 return "json"; }