zoukankan      html  css  js  c++  java
  • ExtJs中gridpanel分组后组名排序

     /**
      * 定义降序的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"
    })
    
  • 相关阅读:
    pycharm快捷键及一些常用设置
    常用笔记
    python开发之路day01
    [转]C++ Unicode SBCS 函数对照表
    PB15151793+PB16001775
    《梦断代码》读书笔记——第四周
    《人件》读书笔记——第三周
    《人月神话》读书笔记——第一周
    软件工程个人作业——词频统计
    《创新者》读书笔记——第五周读书笔记
  • 原文地址:https://www.cnblogs.com/lslvxy/p/3453533.html
Copyright © 2011-2022 走看看