Results 1 to 5 of 5

Thread: Need some help integrating column filters in a grid

  1. #1
    Ext User
    Join Date
    Mar 2010
    Posts
    6
    Vote Rating
    0
      0  

    Default Need some help integrating column filters in a grid

    Hello community,

    as you can see, that's my first post in here

    Just started with ExtJS and now I am at a point, where I didn't found some help in example codes or elsewhere. So I try the forum.

    I create a grid by the followig code:
    Code:
    Ext.namespace('anExtension'); 
    
    anExtension  = Ext.extend(Ext.grid.GridPanel, {
        constructor: function(config)  {
        
        config = Ext.apply({
                title: 'Test',
                 region: 'center',
                viewConfig: {
                     forceFit: true
                    }, 
                loadMask:true,
                 store: store,
                columns: anExtension.MainColumns,
            }, config);
        
            anExtension.superclass.constructor.call(this, config);
        },
    });
    The grid is rendered and everything works fine. Now, I try to add some column filters. Injected the necessary js files and try to add filters like this:
    Code:
    var filters = new Ext.ux.grid.GridFilters({
                             encode: false,
                            local:  true,
                            filters: [{
                                 type: 'string',
                                dataIndex: 'title'
                             }]
    });
    then I add

    Code:
    plugins:[filters]
    to the grid config. But I failed. Just got the following error:

    Ext.ux.grid.GridFilters is undefined in GridFilters.js (459):
    return Ext.ux.grid.filter[type.substr(0, 1).toUpperCase() + type.substr(1) + 'Filter'];


    Can anyone give me a clue on how I can add filters in my Extension grid?
    Thanks for your help!

    regards
    Mario

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890
    Vote Rating
    90
      0  

    Default

    The plugin needs fixing for 3.2.0.

    The "type" is no longer a String.

    Should have been done... slapped wrists...

  3. #3
    Ext User
    Join Date
    Mar 2010
    Posts
    6
    Vote Rating
    0
      0  

    Default

    Hi Animal,

    wow, your're pretty fast. Thanks for your answer. Unfortunatelly I am using still the 3.0 Version and at the moment there is no way to update this.

    Is the plugin not working with 3.0? I thought the problem was my inplementation of the filters not the plugin, isn't it?

    regards
    Mario

  4. #4
    Ext User
    Join Date
    Mar 2010
    Posts
    6
    Vote Rating
    0
      0  

    Default

    To prevent all misunderstandings I post the complete code again:

    Code:
    Ext.namespace('anExtension'); 
    
    anExtension  = Ext.extend(Ext.grid.GridPanel, {
        constructor: function(config)  {
        
        var filters = new Ext.ux.grid.GridFilters({
                             encode: false,
                            local:  true,
                            filters: [{
                                 type: 'string',
                                dataIndex: 'title'
                             }]
    
        });
        config = Ext.apply({
                title: 'Test',
                 region: 'center',
                plugins[filters],
                viewConfig: {
                     forceFit: true
                    }, 
                loadMask:true,
                 store: store,
                columns: anExtension.MainColumns,
            }, config);
        
            anExtension.superclass.constructor.call(this, config);
        },
    });
    Still got this "undefined"-Error.

    Is it possible to define the filters at this point of code?

    Thanks for any hint.
    Mario

  5. #5
    Sencha User Stormseeker's Avatar
    Join Date
    Jan 2010
    Location
    Evanston, Illinois
    Posts
    59
    Vote Rating
    3
      0  

    Default

    Oh man, I thought I was going crazy. Glad I did a forum search for this as I am running into this as well. I created this override as a temporary fix and it seems to be working...

    Code:
        Ext.override(Ext.ux.grid.GridFilters, {
    
            addFilters : function (filters) {
                if (filters) {
                    var i, len, filter, cm = false, dI;
                    if (filters instanceof Ext.grid.ColumnModel) {
                        filters = filters.config;
                        cm = true;
                    }
                    for (i = 0, len = filters.length; i < len; i++) {
                        filter = false;
                        if (cm) {
                            dI = filters[i].dataIndex;
                            filter = filters[i].filter || filters[i].filterable;
                            if (filter){
                                filter = (filter === true) ? {} : filter;
                                Ext.apply(filter, {dataIndex:dI});
                                // filter type is specified in order of preference:
                                //     filter type specified in config
                                //     type specified in store's field's type config
                                filter.type = filter.type || this.store.fields.get(dI).type.type;
                            }
                        }
                        else {
                            filter = filters[i];
                        }
                        // if filter config found add filter for the column
                        if (filter) {
                            this.addFilter(filter);
                        }
                    }
                }
            }
            
        });
    Anyway this can get fixed for 3.2.2?

    Thanks,
    Tim
    Last edited by Stormseeker; 26 May 2010 at 11:33 AM. Reason: Random question

Posting Permissions

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