Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: GridFilter: how to explicitly set the filter values

  1. #11
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Montreal, Canada
    Posts
    255
    Vote Rating
    7
      0  

    Default

    i've added to FiltersFeature.js the following:

    Code:
        /**
         *  progamatically activate a filter field with data
         * @param field the field dataIndex
         * @param data the data from  from @link Ext.ux.grid.FiltersFeature.getFilterData
         */
        setFilterData: function(field, data){
            if (typeof this.view.headerCt.menu == 'undefined'){
                this.forceMenuCreation();
            }
            var filter = this.getFilterByName(field);
            var value = this.unSerialArg(data);
            filter.setValue(value);
        },
    
    
        /**
         *  format  a value from getFilterData to be set into field
         * @param data object returned from @link Ext.ux.grid.FiltersFeature.getFilterData
         */
        unSerialArg: function(data){
            var value={};
            if (data.type == 'numeric'){
                value[data.comparison] = data.value;
            }
            else {
                value =data.value;
            }
            return value;
    
    
        },
    
    
        /**
         * if the menu have not been created, force it's creation
         */
        forceMenuCreation: function(){
            var gridMenu = this.view.headerCt.getMenu();
            this.onMenuCreate(this.headerCt, gridMenu);
        }
    and in my grids, I'm listening to the afterrender method and my the setFilterData method

  2. #12
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Montreal, Canada
    Posts
    255
    Vote Rating
    7
      0  

    Default

    looking into it, unSerialArg method is only for strings and int. I have not touched other data types. So you may have to improve this.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •