ExtJs中gridpanel分组后组名排序实例代码

2019-12-24,,,,


复制代码 代码如下:
/**
  * 定义降序的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"
})


您可能感兴趣的文章:

  • Extjs4实现两个GridPanel之间数据拖拽功能具体方法
  • ExtJs设置GridPanel表格文本垂直居中示例
  • Extjs4 GridPanel 的几种样式使用介绍
  • Extjs4 GridPanel的主要配置参数详细介绍
  • Extjs中的GridPanel隐藏列会显示在menuDisabled中解决方法
  • Extjs EditorGridPanel中ComboBox列的显示问题
  • Extjs gridpanel 出现横向滚动条问题的解决方法
  • ExtJs GridPanel简单的增删改实现代码
  • ExtJS 2.0 GridPanel基本表格简明教程
  • ExtJS GridPanel 根据条件改变字体颜色
  • JavaScript的Ext JS框架中的GridPanel组件使用指南

《ExtJs中gridpanel分组后组名排序实例代码.doc》

下载本文的Word格式文档,以方便收藏与打印。