复制代码 代码如下:
/**
* 定义降序的groupingstore
*/
var descgroupingstore = ext.extend(ext.data.groupingstore, {
groupdir : 'asc',
groupby : function(field, forceregroup, direction) {
direction = direction ? (string(direction)
.touppercase() == 'desc' ? 'desc' : 'asc')
: this.groupdir;
if (this.groupfield == field
this.groupdir == direction && !forceregroup) {
return;
}
this.groupfield = field;
this.groupdir = direction;
if (this.remotegroup) {
if (!this.baseparams) {
this.baseparams = {};
}
this.baseparams['groupby'] = field;
this.baseparams['groupdir'] = direction;
}
if (this.grouponsort) {
this.sort(field, direction);
return;
}
if (this.remotegroup) {
this.reload();
} else {
var si = this.sortinfo || {};
if (si.field != field || si.direction != direction) {
this.applysort();
} else {
this.sortdata(field, direction);
}
this.fireevent('datachanged', this);
}
},
applysort : 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 !== false) {
this.groupby(this.groupfield, true, this.groupdir);
return true;
} else {
if (alwaysfirechange === true) {
this.fireevent('datachanged', this);
}
return false;
}
}
});
复制代码 代码如下:
/*************************调用***************************/
// 消息列表数据源
var messagestore = new descgroupingstore({
proxy : new ext.data.httpproxy({
url : listmessgrid.action
}),
reader : myreader,
groupdir : 'desc',
groupfield : 'status',
sortinfo : {
field : 'id',
direction : desc
}
});
messagestore.load();
复制代码 代码如下:
/*****************在gridpanel中添加如下属性*************************************/
view : new ext.grid.groupingview({
showgroupname : false,
grouptexttpl : '{gvalue}:{text} ({[values.rs.length]} {[values.rs.length > 1 ? 封 : 封]})',
showgroupstext : ddd
})
