easyui中的datagrid表格的序号默认在翻页时是不累加,每一页都是从1~pageSize值,如下:
现在需要让这个表格翻页时序号是累加的,方式如下:
添加序号列
<div class=“region-center” data-options=“region:‘center’,border:false”>
<table id=“ad” class=“easyui-datagrid”
data-options=“singleSelect:false,striped:true,pagination:true,fit:true,method:‘post’,title:‘广告列表’”>
<thead>
<tr>
<th data-options="field:'rowNumber',align:'center',formatter:formatId">序号</th>
…
</tr>
</thead>
</table>
</div>
序号递增函数:
function formatId(value,row,index) {
var op = $('#ad').datagrid('getPager').pagination('options');
return op.pageSize*(op.pageNumber-1)+(index+1);
}