复制代码代码如下:
/**
* 定义降序的groupingStore
*/
var DescGroupingStore = Ext.extend(Ext.data.GroupingStore, {
groupDir: 'ASC',
groupBy : function(campo, forceRegroup, direção) {
direção = direção? (String(direção)
.toUpperCase() == 'DESC'? 'DESC': 'ASC')
: this.groupDir;
if (this.groupField == campo
this.groupDir == direção &&!forceRegroup) {
retornar;
}
this.groupField = campo;
this.groupDir = direção;
if (este.gruporemote) {
if (!this.baseParams) {
this.baseParams = {};
}
this.baseParams['groupBy'] = campo;
this.baseParams['groupDir'] = direção;
}
if (this.groupOnSort) {
this.sort(campo, direção);
retornar;
}
if (este.gruporemote) {
this.reload();
} outro {
var si = this.sortInfo || {};
if (si.field != campo || si.direction != direção) {
this.applySort();
} outro {
this.sortData(campo, direção);
}
this.fireEvent('datachanged', this);
}
},
aplicarSort : function() {
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: function(alwaysFireChange) {
if (this.groupField! == falso) {
this.groupBy(this.groupField, true, this.groupDir);
retornar verdadeiro;
} outro {
if (alwaysFireChange === verdadeiro) {
this.fireEvent('datachanged', this);
}
retornar falso;
}
}
});
复制代码代码如下:
/*************************调用************************* ****/
// 消息列表数据源
var mensagemStore = new DescGroupingStore({
proxy: novo Ext.data.HttpProxy({
url: "listMessGrid.action"
}),
leitor: meuLeitor,
groupDir: 'DESC',
groupField: 'status',
sortInfo: {
campo: 'id',
direção: "DESC"
}
});
mensagemStore.load();
复制代码代码如下:
/*****************在gridpanel中添加如下属性************************** ***********/
visualização: novo Ext.grid.GroupingView({
showGroupName: falso,
groupTextTpl: '{gvalue}:{text} ({[values.rs.length]} {[values.rs.length > 1? "封": "封"]})',
showGroupsText: "ddd"
})