本文為大家分享了bootstrap-table 分頁的問題,供大家參考,具體內容如下
問題1 :伺服器端取不到form值,querystring沒有問題,但是request.form取不到值
解決:這是ajax的問題,原始碼使用原生的ajax。 1可以用讀流檔案解決。 2 如果想用request.form 方式,設定 contentType: "application/x-www-form-urlencoded",
如
$('#tableList').bootstrapTable({ method: 'post', url: "", height: $(window).height() - 200, striped: true, dataType: "json", pagination: true, "queryParamsType": "limit", singleSelect: false, contentType: "application/x-www-form-urlencoded",
問題2、設定傳遞到伺服器的參數
3、方法:
reee取不到pageSize 資訊解決:1在queryParams中設定2 在bootstrap-table.minjs檔案修改來源檔案為"limit"=====.options.queryParamsType&(e={ligmit&(e={ .pageSize,pageNumber:e.pageNumber,修改bootstrap-table.js 也可以function queryParams(params) { return { pageSize: params.limit, pageNumber: params.pageNumber, UserName: 4 }; } $('#tableList').bootstrapTable({ method: 'post', url: "", height: $(window).height() - 200, striped: true, dataType: "json", pagination: true, queryParams: queryParams,
if (this.options.queryParamsType === 'limit') { params = { search: params.searchText, sort: params.sortName, order: params.sortOrder }; if (this.options.pagination) { params.limit = this.options.pageSize; params.pageNumber=this.options.pageNumber, params.offset = this.options.pageSize * (this.options.pageNumber - 1); } }
<script type="text/javascript"> $(document).ready(function() { $('#tableList').bootstrapTable({ method: 'post', url: "getcompapylist", height: $(window).height() - 200, striped: true, dataType: "json", pagination: true, "queryParamsType": "limit", singleSelect: false, contentType: "application/x-www-form-urlencoded", pageSize: 10, pageNumber:1, search: false, //不显示 搜索框 showColumns: false, //不显示下拉框(选择显示的列) sidePagination: "server", //服务端请求 queryParams: queryParams, //minimunCountColumns: 2, responseHandler: responseHandler, columns: [ { field: 'CompanyId', checkbox: true }, { field: 'qq', title: 'qq', width: 100, align: 'center', valign: 'middle', sortable: false } , { field: 'companyName', title: '姓名', width: 100, align: 'center', valign: 'middle', sortable: false } ] }); }); function responseHandler(res) { if (res.IsOk) { var result = b64.decode(res.ResultValue); var resultStr = $.parseJSON(result); return { "rows": resultStr.Items, "total": resultStr.TotalItems }; } else { return { "rows": [], "total": 0 }; } } //传递的参数 function queryParams(params) { return { pageSize: params.limit, pageNumber: params.pageNumber, UserName: 4 }; } </script>