在实现表格列表时,删除最后一页形成最后一页无数据问题;bootstrap
主要是页码超出范围请求数据为空bash
经过修改bootstrap-table.js的initServer方法中的查询success回调函数解决,将该回调函数改成:函数
function (res) {
res = calculateObjectValue(that.options, that.options.responseHandler, [res], res);
/**处理页码错误问题开始 为避免有不分页的数据判断total*/
if(res.total!=undefined&&res.total!=0&&res.data.length==0){//总记录数大于0,但当前页记录数为0,则此时页码超过了最大页码误
that.options.pageNo = Math.ceil(res.total/that.options.pageSize);//最后一页(总页数)
that.initServer();
return;
}
/**处理页码错误问题结束*/
that.load(res);
that.trigger('load-success', res);
}
复制代码
即当总记录数不为0而当前页的记录数为0时将页码设为最后一页从新请求数据:ui
if(res.total!=undefined&&res.total!=0&&res.data.length==0){//总记录数大于0,但当前页记录数为0,则此时页码超过了最大页码误
that.options.pageNo = Math.ceil(res.total/that.options.pageSize);//最后一页(总页数)
that.initServer();
return;
}
复制代码
在onLoadSuccess中判断这里个人入参是pageNo和pageSize
if(datas.total!=undefined&&datas.total!=0&&datas.rows.length==0){//总记录数大于0,但当前页记录数为0,则此时页码超过了最大页码误
that.pageNo = Math.ceil(datas.total/that.pageSize);//最后一页(总页数)
$(this).datagrid("reload");
return;
}
复制代码