Results 1 to 3 of 3

Thread: [FIXED-EXTJSIV-864][B2] Grid filter feature does not get filters from columns

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha Premium Member robboerman's Avatar
    Join Date
    Nov 2007
    Location
    Pijnacker, the Netherlands
    Posts
    94

    Default [FIXED-EXTJSIV-864][B2] Grid filter feature does not get filters from columns

    Hi there,

    I am testing the filter feature for grids, in the example it is specified that filters can be defined in the grid's column config as well as in the feature instance itself. This is correct, but there is a bug in the handling of the grid column filters:

    The attachEvents function calls me.addFilters and gives the grid colums as arguments. This is not correct as that function expects an array of filter configs.

    I fixed this myself by overriding the attachEvents function with the following (Patch is marked)

    Code:
    /* Filter feature does not get the filter configs out of grid columns correctly (B2) */
    Ext.override(Ext.ux.grid.FiltersFeature, {
    	attachEvents: function() {
    		var me = this,
    		view = me.view,
    		headerCt = view.headerCt,
    		grid = me.getGridPanel();
    
    		me.bindStore(view.getStore(), true);
    
    		/* BEGIN PATCH */
    		// assumes no filters were passed in the constructor, so try and use ones from the colModel
    		if (me.filters.getCount() < 1) {
    			//Get columns that specify a filter object and inject the dataIndex key
    			var filters = headerCt.items.items.filter(
    			function(col) {
    				return typeof(col.filter) == 'object';
    			}
    			).map(
    			function(col) {
    				return Ext.apply(col.filter, {
    					dataIndex: col.dataIndex
    				});
    			}
    			) || [];
    			me.addFilters(filters);
    			/* END PATCH */
    		}
    
    		// Listen for header menu being shown
    		headerCt.getMenu().on('beforeshow', me.onMenuBeforeShow, me);
    
    		view.on('refresh', me.onRefresh, me);
    		grid.on({
    			scope: me,
    			beforestaterestore: me.applyState,
    			beforestatesave: me.saveState,
    			beforedestroy: me.destroy
    		});
    
    		// Add event and filters shortcut on grid panel
    		grid.filters = me;
    		grid.addEvents('filterupdate');
    	}
    });
    The code also specifies that the 'filterable: true' key can be set, but this is broken as well

    Cheers and good luck

  2. #2
    Sencha User dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,748

    Default

    Thanks for the bug report and patch! This should be fixed in 4.0.2.
    Don Griffin

    "Use the source, Luke!"

  3. #3
    Sencha User
    Join Date
    Jun 2008
    Posts
    157

    Default

    I modified this patch to allow getting the config from the store when the filterable option is true.

    Code:
           attachEvents: function() {
                var me = this,
                view = me.view,
                headerCt = view.headerCt,
                grid = me.getGridPanel(),
                dI, filter; // PATCH VARIABLES
    
                me.bindStore(view.getStore(), true);
    
                /* BEGIN PATCH */
                // assumes no filters were passed in the constructor, so try and use ones from the colModel
                if (me.filters.getCount() < 1) {
                    //Get columns that specify a filter object and inject the dataIndex key
                    var filters = headerCt.items.items.filter(
                    function(col) {
                        return typeof(col.filter) == 'object' || col.filterable;
                    }
                    ).map(
                    function(col) {
                        dI = col.dataIndex;
                        col.filter = col.filter || {};
                        // filter type is specified in order of preference:
                        //     filter type specified in config
                        //     type specified in store's field's type config
                        return Ext.apply(col.filter , {
                            dataIndex:dI,
                            type: col.filter.type || view.getStore().model.prototype.fields.get(dI).type.type
                        });
                    }
                    ) || [];
                    me.addFilters(filters);
                }
                /* END PATCH */
    
                // Listen for header menu being shown
                headerCt.getMenu().on('beforeshow', me.onMenuBeforeShow, me);
    
                view.on('refresh', me.onRefresh, me);
                grid.on({
                    scope: me,
                    beforestaterestore: me.applyState,
                    beforestatesave: me.saveState,
                    beforedestroy: me.destroy
                });
    
                // Add event and filters shortcut on grid panel
                grid.filters = me;
                grid.addEvents('filterupdate');
            }
    Is there a repository where I can contribute or is it done all through the forums?? Or maybe it's only for paying users??

Similar Threads

  1. Replies: 3
    Last Post: 1 Apr 2011, 12:22 AM
  2. Need help regarding Grid Filter feature
    By RadhaS in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 19 Oct 2010, 10:32 PM
  3. Replies: 1
    Last Post: 19 Jan 2010, 10:59 PM
  4. Grid columns, how to disable filters?
    By salsa in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 1 Jul 2008, 4:34 AM
  5. Why I can't clear the filters' cookies of the plugin grid filter
    By safewolf in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 14 Mar 2008, 2:36 AM

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
  •