複製程式碼如下:
/**
* 定義降序的分組存儲
*/
var DescGroupingStore = Ext.extend(Ext.data.GroupingStore, {
群組目錄:'ASC',
groupBy : 函數(場, 力重組, 方向) {
方向=方向? (字串(方向)
.toUpperCase() == 'DESC' ? 「降序」:「升序」)
: 這個.groupDir;
if (this.groupField == 字段
this.groupDir == 方向 && !forceRegroup) {
返回;
}
this.groupField = 字段;
this.groupDir = 方向;
if (this.remoteGroup) {
if (!this.baseParams) {
this.baseParams = {};
}
this.baseParams['groupBy'] = 欄位;
this.baseParams['groupDir'] = 方向;
}
if (this.groupOnSort) {
this.sort(字段, 方向);
返回;
}
if (this.remoteGroup) {
this.reload();
} 別的 {
var si = this.sortInfo || {};
if (si.field != field || si.direction != 方向) {
this.applySort();
} 別的 {
this.sortData(字段, 方向);
}
this.fireEvent('datachanged', this);
}
},
應用排序:函數(){
Ext.data.GroupingStore.superclass.applySort.call(this);
if (!this.groupOnSort && !this.remoteGroup) {
if (this.groupField != this.sortInfo.field
|| this.groupDir != this.sortInfo.direction) {
this.sortData(this.groupField, this.groupDir);
}
}
},
applyGrouping : 函數(alwaysFireChange) {
if (this.groupField !== false) {
this.groupBy(this.groupField, true, this.groupDir);
返回真;
} 別的 {
如果(alwaysFireChange === true){
this.fireEvent('datachanged', this);
}
返回假;
}
}
});
複製程式碼如下:
/************************呼叫************************ ****/
// 訊息清單資料來源
var messageStore = new DescGroupingStore({
代理:新的 Ext.data.HttpProxy({
url : "listMessGrid.action"
}),
讀者:我的讀者,
群組目錄:'DESC',
groupField : '狀態',
排序資訊:{
字段:'id',
方向:“DESC”
}
});
messageStore.load();
複製程式碼如下:
/********************在gridpanel中新增下列屬性*********************** ***** **********/
檢視:新的 Ext.grid.GroupingView({
顯示群組名稱:假,
groupTextTpl : '{gvalue}:{text} ({[values.rs.length]} {[values.rs.length > 1 ? "封" : "封"]})',
顯示群組文字:“ddd”
})