bootstrap-table 显示行号,分页有效
来源:互联网 发布:delphi 车牌识别算法 编辑:程序博客网 时间:2024/06/09 20:57
使用bootstrap-table进行表格展示时,总觉得不显示行号有点别扭,于是网上找办法。看到下面的文章:
bootstrap table 行号 显示行号 添加行号 bootstrap-table 行号
首先感谢原作者。
思想:借助bootstrap-table 本身的index属性, 巧妙的的通过formatter 实现{field: 'Number',title: 'Number',formatter: function (value, row, index) {return index+1;}}
但是翻页后,行号还是会从1开始,没有连接上一页的。
翻看bootstrap-table的源码,可以看到它的配置项都放在一个叫做options的对象里,包括页码pageNumber和页面大小pageSize,同样也有pageFrom和pageTo两个变量,表示当前页起始和结束的行号索引。
试试修改源码,增加获取pageNumber和pageSize参数的方法。我用的版本是1.6.0,修改如下:
1)增加getPage方法,获取当前设置的页码,和每页行数:
BootstrapTable.prototype.getPage = function (params) { return {pageSize: this.options.pageSize, pageNumber: this.options.pageNumber};};
2)修改allowedMethods对象,增加getPage:
var allowedMethods = [ 'getOptions', 'getSelections', 'getData', 'load', 'append', 'prepend', 'remove', 'insertRow', 'updateRow', 'showRow', 'hideRow', 'mergeCells', 'checkAll', 'uncheckAll', 'check', 'uncheck', 'checkBy', 'uncheckBy', 'refresh', 'getPage', 'resetView', 'destroy', 'showLoading', 'hideLoading', 'showColumn', 'hideColumn', 'filterBy', 'scrollTo', 'selectPage', 'prevPage', 'nextPage', 'togglePagination', 'toggleView' ];
3)调用的地方通过getPage方法:
columns : [{field : 'Number',title : '行号',formatter : function(value, row, index) {//return index + 1;var page = $table.bootstrapTable("getPage");return page.pageSize * (page.pageNumber - 1) + index + 1;}},//......
这样的话,在bootstrap-table分页的情况下,也会连续的显示行号。当然获取上面提到的另外两个变量应该也可以获取。
0 0
- bootstrap-table 显示行号,分页有效
- bootstrap table 显示行号
- bootstrap-table 显示行号
- bootstrap-table显示行号
- bootStrap table实现分页
- BootStrap-Table 分页
- Bootstrap Table分页例子
- bootstrap-table后端分页
- bootstrap-table分页问题
- bootstrap table 分页
- bootstrap table 分页例子
- BootStrap table分页
- bootstrap-table分页
- ssm分页+bootstrap-table
- bootstrap-table分页小结
- bootstrap-table 分页
- bootstrap-table 分页
- bootstrap-table真分页
- Android6.0权限组
- n个元素的所有子集(递归+非递归 +不去重)
- Imooc·Java高并发秒杀API(枚举与异常处理)
- R语言实战:机器学习与数据分析源代码2
- 异常Error running app: Instant Run requires 'Tools | Android | Enable ADB integration' to be enabled.
- bootstrap-table 显示行号,分页有效
- Android中BindService方式使用的例子
- c++,父类引用指向子类对象,虚函数
- java小知识
- 计算机图形学(二)输出图元_20_章节总结_程序展示_饼图
- 第六章 最短路径
- Node 出现 uncaughtException 之后的优雅退出方案
- [工具]Mac电脑如何直接管理安卓手机内存文件
- 为什么360浏览器兼容模式文档模式默认以ie7标准渲染