bootstrap-table后台分页时前台删除最后一页所有数据refresh刷新后无数据问题。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xinshijimanon/article/details/53813204

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

function (res) {
            	/**TODO:2016-12-20新加的代码,处理页码错误问题开始*/
            	if(that.options.pagination&&res.total&&!res.rows.length){//总记录数大于0,但当前页记录数为0,则此时页码超过了最大页码误
            		that.options.pageNumber = Math.ceil(res.total/that.options.pageSize);//最后一页(总页数)
            		that.initServer();
            		return;
            	}
            	/**2016-12-20新加的代码,处理页码错误问题结束*/
                res = calculateObjectValue(that.options, that.options.responseHandler, [res], res);

                that.load(res);
                that.trigger('load-success', res);
            }
当总记录数不为0而当前页的记录数为0时将页码设为最后一页重新请求数据,即:
if(that.options.pagination&&res.total&&!res.rows.length){//总记录数大于0,但当前页记录数为0,则此时页码超过了最大页码误
            		that.options.pageNumber = Math.ceil(res.total/that.options.pageSize);//最后一页(总页数)
            		that.initServer();
            		return;
            	}



猜你喜欢

转载自blog.csdn.net/xinshijimanon/article/details/53813204