Results 1 to 3 of 3

Thread: [5.1.0] TriFilter does not cope with falsey filter values

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,037

    Default [5.1.0] TriFilter does not cope with falsey filter values

    Hi guys,

    Long(ish) time no issue raise

    We've just found an issue with activating and deactivating number grid filters when their value is zero.
    (For a test case pick a filterable grid from kitchen sink I guess, and apply a zero valued filter, then deactivate and re-activate).

    Tracked down the issue to TriFilter.
    Here's my override:
    Code:
        Ext.define('Altus.overrides.grid.filters.filter.TriFilter', {
            override: 'Ext.grid.filters.filter.TriFilter',
    
    
            /**
             * Override to cope with a falsey filter value.
             */
            activate: function (showingMenu) {
                var me = this,
                    filters = this.filter,
                    fields = me.fields,
                    filter, field, operator, value;
    
    
                if (me.preventFilterRemoval) {
                    return;
                }
    
    
                for (operator in filters) {
                    filter = filters[operator];
                    field = fields[operator];
                    value = filter.getValue();
    
    
                    // WestyFix: Changed to use Ext.isEmpty so copes with falsey values like zero.
                    // Values starts as null so cannot use isDefined...
                    if (!Ext.isEmpty(value)) {
                        field.setValue(value);
                        field.up('menuitem').setChecked(true, /*suppressEvents*/ true);
    
    
                        // Note that we only want to add store filters when they've been removed, which means that when Filter.showMenu() is called
                        // we DO NOT want to add a filter as they've already been added!
                        if (!showingMenu) {
                            me.addStoreFilter(filter);
                        }
                    }
                }
            },
    
    
            /**
             * Override to cope with a falsey filter value.
             */
            deactivate: function () {
                var me = this,
                    filters = me.filter,
                    f, filter;
    
    
                if (!me.hasActiveFilter() || me.preventFilterRemoval) {
                    return;
                }
    
    
                me.preventFilterRemoval = true;
    
    
                for (f in filters) {
                    filter = filters[f];
    
    
                    // WestyFix: Changed to use Ext.isEmpty so copes with falsey values like zero.
                    // Values starts as null so cannot use isDefined...
                    if (!Ext.isEmpty(filter.getValue())) {
                        me.removeStoreFilter(filter);
                    }
                }
    
    
                me.preventFilterRemoval = false;
            }
        });
    Not checked latest code base since having trouble logging into the support portal to download them - have kicked someone here to renew our license that ran out last week.

    Cheers,
    Westy
    Product Architect
    Altus Ltd.

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,257

    Default

    Current code reads (for both methods)

    Code:
    if (value || value === 0)
    So that should be sufficient.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,037

    Default

    Cool.
    I did search for an issue, but didn't find one.

    My support access has now been restored, so that's good

    Cheers
    Product Architect
    Altus Ltd.

Similar Threads

  1. [CLOSED] Grid clear filter not clearing the filter values.
    By sandeep m in forum Ext 5: Bugs
    Replies: 6
    Last Post: 25 Sep 2018, 10:11 AM
  2. [CLOSED] Accordion does not cope with header: false;
    By bimargulies in forum Ext:Bugs
    Replies: 1
    Last Post: 16 Aug 2012, 2:23 PM
  3. Replies: 1
    Last Post: 27 Jun 2012, 4:00 PM
  4. Can Ext JS cope with predeclared and additional entities in the XML?
    By leese in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 2 Jun 2009, 8:24 AM
  5. How does Ext cope with Google SEO?
    By woocash_k in forum Community Discussion
    Replies: 2
    Last Post: 22 Jan 2008, 2:20 PM

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
  •