Bootstrap-table常见分页问题有哪些

发布时间:2021-09-23 18:29:03 作者:小新
来源:亿速云 阅读:155

这篇文章主要为大家展示了“Bootstrap-table常见分页问题有哪些”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“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: 设置传递到服务器的参数

方法:

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中设置

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);}}

3、配置加入  "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", //服务端请求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>

问题4:分页后,重新搜索的问题

前提:自定义搜索且有分页功能,比如搜索产品名的功能.

现象:当搜索充气娃娃的时候返回100条记录,翻到第五页.  这时候搜索按摩棒,数据有200条,结果应该是第一页的记录,但是实际显示的还是第五页的结果.  也就是重新搜索后,pagenumber没有变.

解决:重新设置option就行了.

 function search(){     $('#tableList').bootstrapTable({pageNumber:1,pageSize:10});}

以上是“Bootstrap-table常见分页问题有哪些”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

推荐阅读:
  1. MyEclips常见问题有哪些
  2. 如何使用Bootstrap-Table实现分页和排序

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

bootstrap bootstrap-table

上一篇:Bootstrap-table如何实现动态合并相同行

下一篇:使用bootstrap框架的好处是什么

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》