Extjs之RowNumberer
生活随笔
收集整理的這篇文章主要介紹了
Extjs之RowNumberer
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Ext.grid.RowNumberer,Ext.grid.PageRowNumberer
在一個(gè)數(shù)據(jù)表格中,一般都會(huì)加一個(gè)行號(hào),在ExtJs中,要實(shí)現(xiàn)行號(hào)這一效果,只需要一句代碼:
new Ext.grid.RowNumberer()舉個(gè)例子,代碼如下:
var colModel = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(),{ header: "擦寫機(jī)器號(hào)", width: 100, dataIndex: 'JSON_no_machine' },{ header: "寫入服務(wù)器時(shí)間", width: 150, dataIndex: 'JSON_time_insert' },{ header: "現(xiàn)居住地址", width: 250, dataIndex: 'JSON_xjzdz' },{ header: "服務(wù)處所", width: 100, dataIndex: 'JSON_fwcs' },{ header: "擦寫日期", width: 150, dataIndex: 'JSON_cxrq' },{ header: "擦寫單位", width: 150, dataIndex: 'JSON_cxdwmc' },{ header: "姓名", width: 50, dataIndex: 'JSON_xm' },{ header: "身份證號(hào)碼", width: 150, dataIndex: 'JSON_sfzhm' },{ header: "擦寫時(shí)間", width: 150, dataIndex: 'JSON_make_time' },]);但有些時(shí)候,我們需要的效果是實(shí)際的行號(hào),是翻頁(yè)之后,行號(hào)不會(huì)重置為1,而是從在上一頁(yè)的最后一條記錄的行號(hào)的基礎(chǔ)上繼續(xù)遞增.這個(gè)時(shí)候,我們需要對(duì)Ext.grid.RowNumberer
進(jìn)行一下擴(kuò)展:
Ext.grid.PageRowNumberer = Ext.extend(Ext.grid.RowNumberer, { width : 40, renderer:function(value, cellmeta, record, rowIndex, columnIndex, store){ if(store.lastOptions.params!=null){ var pageindex=store.lastOptions.params.start; return pageindex + rowIndex + 1; } else { return rowIndex + 1; } } });rowIndex是本頁(yè)表格的行號(hào),從0開始,pageindex取至每頁(yè)的Start參數(shù),也是從0開始,那么根據(jù)"從在上一頁(yè)的最后一條記錄的行號(hào)的基礎(chǔ)上繼續(xù)遞增",當(dāng)前記錄的行號(hào)就為:
pageindex + rowIndex + 1;舉個(gè)例子,代碼如下:
//實(shí)際行號(hào)Ext.grid.PageRowNumberer = Ext.extend(Ext.grid.RowNumberer, {width: 40,renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {if (store.lastOptions.params != null) {var pageindex = store.lastOptions.params.start;return pageindex + rowIndex + 1;} else {return rowIndex + 1;}}});var colModel = new Ext.grid.ColumnModel([// new Ext.grid.RowNumberer(),new Ext.grid.PageRowNumberer(),{ header: "擦寫機(jī)器號(hào)", width: 100, dataIndex: 'JSON_no_machine' },{ header: "寫入服務(wù)器時(shí)間", width: 150, dataIndex: 'JSON_time_insert' },{ header: "現(xiàn)居住地址", width: 250, dataIndex: 'JSON_xjzdz' },{ header: "服務(wù)處所", width: 100, dataIndex: 'JSON_fwcs' },{ header: "擦寫日期", width: 150, dataIndex: 'JSON_cxrq' },{ header: "擦寫單位", width: 150, dataIndex: 'JSON_cxdwmc' },{ header: "姓名", width: 50, dataIndex: 'JSON_xm' },{ header: "身份證號(hào)碼", width: 150, dataIndex: 'JSON_sfzhm' },{ header: "擦寫時(shí)間", width: 150, dataIndex: 'JSON_make_time' },]);
?
?
?
NED
?轉(zhuǎn)載于:https://www.cnblogs.com/Francis-YZR/p/4896021.html
總結(jié)
以上是生活随笔為你收集整理的Extjs之RowNumberer的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: win32com 操作excel
- 下一篇: shell转化bat工具_shell脚本