Results 1 to 2 of 2

Thread: How to retain previous filter on checkbox extjs 4.1

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    48
    Vote Rating
    1
      0  

    Default Answered: How to retain previous filter on checkbox extjs 4.1

    Hey everyone... I am trying to use this checkbox filter... where a user clicks and then shows list of states on a grid that's only cold... when the user unchecks, I want the store to be back on the previous state... I don't want to use the store.clearfilter() because it just clears my previous filter... I want to retain the previous filter (which is triggered from another combox)... Here's my code that i am trying to use.. but it says
    Code:
    TypeError: a.getRoot.call(a, d) is undefined
    please help... is there another way to implement this? thanks
    Code:
        items: [{
                        xtype: 'checkboxfield',
                        boxLabel: 'Show only Cold State',
                        scope: this,
                        handler: function (field, value) {
                            scope: this,
                            this.checkValue = field.getValue();
                            console.log(this.checkValue);
                            if (this.checkValue == true) {
                                var tempstore1 = Ext.getCmp('GridArea1').store;
                                    tempstore1.filters.add('CheckBoxFilter', new Ext.util.Filter({
                                        property: 'Cold',
                                        value: 'Yes',
                                        root: 'myTable'
                                    }));
                                    console.log('here');
                                    tempstore1.load();
                            }
                            else if (this.checkValue == false) {
                                     this.store.filters.removeAtKey('CheckBoxFilter');
                            }
                        },

  2. Some code that may help you:

    Code:
        clearFilter: function() {
            var store = this.store,
                filter = this.activeFilter,
                filters = store.filters,
                remaining;
                
            if (filter) {
                if (filters.getCount() > 1) {
                    // More than 1 existing filter
                    filters.remove(filter);
                    remaining = filters.getRange();
                }
                store.clearFilter(true);
                if (remaining) {
                    store.filter(remaining);
                }
            }
            return !!filter;
        },

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,416
    Answers
    3899
    Vote Rating
    1269
      0  

    Default

    Some code that may help you:

    Code:
        clearFilter: function() {
            var store = this.store,
                filter = this.activeFilter,
                filters = store.filters,
                remaining;
                
            if (filter) {
                if (filters.getCount() > 1) {
                    // More than 1 existing filter
                    filters.remove(filter);
                    remaining = filters.getRange();
                }
                store.clearFilter(true);
                if (remaining) {
                    store.filter(remaining);
                }
            }
            return !!filter;
        },
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

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
  •