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);
}