Copy Code code as follows:
/**
* Defines a descending 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;
}
}
});
Copy Code code as follows:
/************************* Call ***************************/
Message list data source
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 ();
Copy Code code as follows:
/***************** adds the following properties to the Gridpanel *************************************/
View:new Ext.grid.GroupingView ({
Showgroupname:false,
Grouptexttpl: ' {gvalue}:{text} ({[values.rs.length]} {[Values.rs.length > 1? "Seal": "Seal"]}) ',
Showgroupstext: "DDD"
})