分享

BootStrap Table后台分页时前台删除最后一页所有数据refresh刷新后无数据问题

 洋yangyang 2017-06-29

主要是页码超出范围带来的问题,仅在此记录一下,这里我通过修改bootstrap-table.js的initServer方法中的查询success回调函数解决,将该回调函数改为:

[javascript] view plain copy
  1. function (res) {  
  2.                 /**TODO:2016-12-20新加的代码,处理页码错误问题开始*/  
  3.                 if(that.options.pagination&&res.total&&!res.rows.length){//总记录数大于0,但当前页记录数为0,则此时页码超过了最大页码误  
  4.                     that.options.pageNumber = Math.ceil(res.total/that.options.pageSize);//最后一页(总页数)  
  5.                     that.initServer();  
  6.                     return;  
  7.                 }  
  8.                 /**2016-12-20新加的代码,处理页码错误问题结束*/  
  9.                 res = calculateObjectValue(that.options, that.options.responseHandler, [res], res);  
  10.   
  11.                 that.load(res);  
  12.                 that.trigger('load-success', res);  
  13.             }  
当总记录数不为0而当前页的记录数为0时将页码设为最后一页重新请求数据,即:
[javascript] view plain copy
  1. if(that.options.pagination&&res.total&&!res.rows.length){//总记录数大于0,但当前页记录数为0,则此时页码超过了最大页码误  
  2.                     that.options.pageNumber = Math.ceil(res.total/that.options.pageSize);//最后一页(总页数)  
  3.                     that.initServer();  
  4.                     return;  
  5.                 }  



    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多