Home  >  Article  >  Web Front-end  >  Example code for sorting group names after gridpanel grouping in ExtJs_javascript skills

Example code for sorting group names after gridpanel grouping in ExtJs_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:11:111590browse

Example code for sorting group names after gridpanel grouping in ExtJs_javascript skills

复制代码 代码如下:

/**
* Define groupingStore in descending order
*/
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;
        }
    }
});

复制代码 代码如下:

/***************************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 The code is as follows:

/*****************Add the following attributes to the gridpanel****************************** ********/
view : new Ext.grid.GroupingView({
showGroupName : false,
groupTextTpl : '{gvalue}:{text} ({[values.rs.length]} {[values.rs.length > 1 ? "closure" : "closure"]})',
showGroupsText : "ddd"
})

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn