【问题标题】:How to rename a local grid filter of type list如何重命名列表类型的本地网格过滤器
【发布时间】:2014-12-19 08:13:48
【问题描述】:

在 Col1 列的“MyGrid”中,我将来自存储 True 或 False 的值更改为 Yes(对于 True)和 No(对于 false)。如果我没有在过滤器下指定任何选项,过滤器列表将显示为 True、False。我想用是(对于真)和否(对于假)进行本地过滤。我怎样才能做到这一点?

Ext.define('TestGrid', {
      requires: [
        'Ext.ux.grid.FiltersFeature'
      ],
      extend: 'Ext.grid.Panel',

      initComponent: function() {
        var myStore = Ext.create('MyStore');

        this.columns = [ 
          {
            text: 'Col1',
            dataIndex: 'Col1',
            sortable: true,
            draggable: false,        
             renderer: function(value, metaData, record, rowIndex, colIndex, store) {
              //changing from true/false to yes/no
               if (value) {
                 return 'Yes';
             } else {
             return 'No;
             }
             }                    
          }          
        ];

        this.features = [
          {
            ftype: 'filters',
            local: true,
            encode: false,
            filters: [

                      {
                        type: 'list',
                        dataIndex: 'Col1',
                        options: ['Yes', 'No'],
                        phpMode: true                                     
                      }
                      ]
          }          
        ];    
        this.callParent(arguments);
      }
    });

【问题讨论】:

    标签: extjs filter grid


    【解决方案1】:

    找到解决方案!

    validateRecord: function(record) {
    var valArray = this.getValue(), rec = record.get(this.dataIndex), i, re, retval = false, changedValues = [];
    
                                  //for each values in valArray add appropriate value in changedVal //for Yes -> True and No -> False                      
                                  for(i in changedValues) {
                                    re = new RegExp(changedValues[i], 'gi');
                                    if(re.test(rec)) {
                                      retval = true;
                                    }
                                  }
                                  return retval;
                                }                             
    

    【讨论】:

      【解决方案2】:

      更容易(想知道为什么我以前没有尝试过)

       {
                          type: 'list',
                          dataIndex: 'Col1',
                          options: [
                                [true,'Yes'],
                                [false, 'No']                            
                        }
      

      【讨论】:

        猜你喜欢
        • 2020-08-05
        • 2020-06-12
        • 2023-03-06
        • 1970-01-01
        • 1970-01-01
        • 2013-04-09
        • 2012-06-04
        • 1970-01-01
        • 2011-08-25
        相关资源
        最近更新 更多