Bootstrap table分頁問題匯總
首先非常感謝作者針對bootstrap table分頁問題進(jìn)行詳細(xì)的整理,并分享給了大家,希望通過這篇文章可以幫助大家解決Bootstrap table分頁的各種問題,謝謝大家的閱讀。
問題1 :服務(wù)器端取不到form值,querystring沒有問題,但是request.form取不到值
解決:這是ajax的問題,原代碼使用原生的ajax。 1可以用讀流文件解決。2 如果想用request.form 方式,設(shè)置 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: 設(shè)置傳遞到服務(wù)器的參數(shù)
方法:
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,
問題3: 后臺取不到 pageSize 信息
解決:
1、在queryParams中設(shè)置
2、在bootstrap-table.minjs文件 修改源文件為"limit"===this.options.queryParamsType&&(e={limit:e.pageSize,pageNumber:e.pageNumber,
修改 bootstrap-table.js 也可以
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);
}
}
配置加入 "queryParamsType": "limit",
完整:
<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", //服務(wù)端請求
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
};
}
}
//傳遞的參數(shù)
function queryParams(params) {
return {
pageSize: params.limit,
pageNumber: params.pageNumber,
UserName: 4
};
}
</script>
問題4:分頁后,重新搜索的問題
前提:自定義搜索且有分頁功能,比如搜索產(chǎn)品名的功能.
解決:重新設(shè)置option就行了.
function search(){
$('#tableList').bootstrapTable({pageNumber:1,pageSize:10});
}
如果大家還想深入學(xué)習(xí),可以點擊這里進(jìn)行學(xué)習(xí),再為大家附3個精彩的專題:
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助。
相關(guān)文章
JS實現(xiàn)用特殊符號替換字符串的中間部分區(qū)域的實例代碼
相信很多人都遇到過敏感信息需要做部分隱藏功能,大多數(shù)都是用特殊符號去替換。今天小編給大家?guī)砹薐S實現(xiàn)用特殊符號替換字符串的中間部分區(qū)域的實例代碼,需要的朋友參考下吧2018-07-07

