解決JS組件bootstrap table分頁實現(xiàn)過程中遇到的問題
本文為大家分享了bootstrap-table 分頁的問題,供大家參考,具體內(nèi)容如下
問題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í),可以點擊這里進行學(xué)習(xí),再為大家附兩個精彩的專題:Bootstrap學(xué)習(xí)教程 Bootstrap實戰(zhàn)教程
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助。
- bootstrap table 服務(wù)器端分頁例子分享
- 第一次動手實現(xiàn)bootstrap table分頁效果
- Bootstrap table分頁問題匯總
- Bootstrap table兩種分頁示例
- BootStrap中Table分頁插件使用詳解
- BootStrap中的table實現(xiàn)數(shù)據(jù)填充與分頁應(yīng)用小結(jié)
- 基于SpringMVC+Bootstrap+DataTables實現(xiàn)表格服務(wù)端分頁、模糊查詢
- Bootstrap Table服務(wù)器分頁與在線編輯應(yīng)用總結(jié)
- bootstrap table分頁模板和獲取表中的ID方法
- bootstrap Table服務(wù)端處理分頁(后臺是.net)
相關(guān)文章
Bootstrap入門書籍之(五)導(dǎo)航條、分頁導(dǎo)航
這篇文章主要介紹了Bootstrap入門書籍之(五)導(dǎo)航條、分頁導(dǎo)航的相關(guān)資料,需要的朋友可以參考下2016-02-02
Bootstrap學(xué)習(xí)筆記 輪播(Carousel)插件
Bootstrap 輪播(Carousel)插件是一種靈活的響應(yīng)式的向站點添加滑塊的方式。這篇文章主要介紹了Bootstrap學(xué)習(xí)筆記 輪播(Carousel)插件,需要的朋友可以參考下2017-03-03
JS實現(xiàn)網(wǎng)頁上隨機產(chǎn)生超鏈接地址的方法
這篇文章主要介紹了JS實現(xiàn)網(wǎng)頁上隨機產(chǎn)生超鏈接地址的方法,涉及JavaScript隨機數(shù)的相關(guān)使用技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-11-11
JavaScript繼承學(xué)習(xí)筆記【新手必看】
下面小編就為大家?guī)硪黄狫avaScript繼承學(xué)習(xí)筆記。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考2016-05-05
詳談ES6中的迭代器(Iterator)和生成器(Generator)
下面小編就為大家?guī)硪黄斦凟S6中的迭代器(Iterator)和生成器(Generator)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-07-07

