1. 程式人生 > >Extjs4的Grid中rownumberer倒序排序

Extjs4的Grid中rownumberer倒序排序


Extjs4的Grid是最常用的控制元件,序號我們一般使用如下程式碼:

columns:[
		{ 
			text:"序號",
			xtype: 'rownumberer',
			width:40
	  }
   ]

這樣是1、2、3、4、5....順序展示

如何倒序展示呢,程式碼如下:

columns:[
		{ 
			text:"診次",
			xtype: 'rownumberer',
			width:40,
			renderer:function(value,metadata,record,rowIndex){
		       return this.store.getTotalCount() -((this.store.currentPage-1)*this.store.pageSize)-rowIndex
		       return 
	  }
		}]

這樣就可以 ....5、4、3、2、1 展示了

this.store.getTotalCount():grid總資料量 
this.store.currentPage:當前頁碼,從1開始
this.store.pageSize:每頁展示的資料量