1. #1
    Sencha User
    Join Date
    May 2011
    Location
    Northern California
    Posts
    255
    Answers
    2
    Vote Rating
    17
    BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about

      0  

    Default Unanswered: How to attach a filter to a store in 4.0.5?

    Unanswered: How to attach a filter to a store in 4.0.5?


    I'm in 4.0.5. I just want to define a filter on a store so that when it loads its data from the API, it only includes a subset of items. The store is set to autoLoad. I see methods on Store for adding filters, but I need to filter to be on the store so that it gets applied when it loads. I'm also using MVC architecture.

    Edit:
    My store is bound to a combobox. In the constructor, I install a filterBy function, and it appears to be getting called, but still the items showing up in the combobox are showing all the items, not just the filtered ones.

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,994
    Answers
    381
    Vote Rating
    183
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    You might look at the Filtering and Sorting sub-section at the top of the API docs for Ext.data.Store.
    http://docs.sencha.com/extjs/4.0.5/#...Ext.data.Store

    Or, if that's not working well for you can you post a snippet of your code of how you're doing it today?

  3. #3
    Sencha User
    Join Date
    May 2011
    Location
    Northern California
    Posts
    255
    Answers
    2
    Vote Rating
    17
    BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about

      0  

    Default


    I've consulted all the docs - the forum is always my last stop. I wound up having to do something like this:
    Code:
                reader: {
                    type: 'json',
                    // Filtering on the store did not work, so filtering directly on the read.
                    getData: function(data) {
                        var
                            newdata = [],
                            record
                        ;
    
                        // Filter the data
                        while (data.length) {
                            record = data.shift();
                            if (_match[record.id]) {
                                newdata.push(record);
                            }
                        }
                        return newdata;
                    }
                }
    Last edited by BillHubbard; 6 May 2013 at 7:02 PM. Reason: type-o

Thread Participants: 1

Tags for this Thread