1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    52
    Answers
    4
    Vote Rating
    2
    michael.parrott is on a distinguished road

      0  

    Default Unanswered: problems filtering store

    Unanswered: problems filtering store


    I'm trying to filter a store which comes from the hasMany association of a model.

    Code:
    var newStore = myStore.buildings(); //get all the buildings associated with myStore. The model associated with myStore hasMany Building
    newStore.filter('fieldName', 'attr'); //I want to reduce newStore down to the records which have their fieldName set to 'attr'
    However, using this code does not seem to produce the expected filtering (where newStore now contains only the filtered records). How am I supposed to filter the records?

  2. #2
    Sencha User Diego Garcia's Avatar
    Join Date
    Jan 2012
    Location
    San José, Costa Rica.
    Posts
    85
    Answers
    13
    Vote Rating
    7
    Diego Garcia is on a distinguished road

      0  

    Default


    I've seen like that way to filter is not working anymore (according some people experience I've read).
    Try passing a function, that worked for me:

    Code:
    newStore.filter(function (record) {
        return record.data.fieldName == 'attr';
    });
    We are a community, let's behave like that.

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    52
    Answers
    4
    Vote Rating
    2
    michael.parrott is on a distinguished road

      0  

    Default


    Unfortunately, that didn't work.
    I thought that the .filterBy method for stores was supposed to take a function for filtering, and I tried using that as well, but it didn't work either.
    I placed a console.log command in the function as well to see if the filtering function was getting called, and it doesn't look like it is.

  4. #4
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,149
    Answers
    132
    Vote Rating
    99
    jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice

      0  

    Default


    Have you tried the method of adding it as a config?
    Code:
    var store = Ext.create("Ext.data.Store", {
        autoLoad: true,
        model: ...,
        proxy: {
            type: "ajax",
            url : ...,
            reader: {
                ...
            }
        },
        sorters: [
            ...
        ],
        filters: [
            {
                property: "fieldName",
                value: /attr/
            }
        ]
    });
    You can also try using a Ext.util.Filter instance like mentioned in the filter method's documentation.

  5. #5
    Sencha User
    Join Date
    Jun 2012
    Posts
    52
    Answers
    4
    Vote Rating
    2
    michael.parrott is on a distinguished road

      0  

    Default


    I can't seem to get either of those methods to work either.

    To give a bit more background info on what I'm trying to do: I've got some data in a JSON file which is loaded into a store. In this JSON file, there is a list of places, one of which is chosen at the start of the program. This record is then saved in a global variable. With each place is an associated array of buildings. Based on a category of buildings a user enters, I want to filter the buildings and show them only the buildings associated with this category.

  6. #6
    Sencha User Diego Garcia's Avatar
    Join Date
    Jan 2012
    Location
    San José, Costa Rica.
    Posts
    85
    Answers
    13
    Vote Rating
    7
    Diego Garcia is on a distinguished road

      0  

    Default


    With that said, I think "var newStore = myStore.buildings();" does not do what you are expecting.

    If you say that your places and buildings come from a json file and their are related by a "hasMany" relationship, "myStore.buildings()" does not return all your buildings.

    You are able to do ".building()" over a single "place" record, not over your main store.

    It seems like the problem is in your data definition/usage instead the store filtering methods.
    We are a community, let's behave like that.

  7. #7
    Sencha User
    Join Date
    Jun 2012
    Posts
    52
    Answers
    4
    Vote Rating
    2
    michael.parrott is on a distinguished road

      0  

    Default


    I think that the .buildings() method does return all of the places because when I have attempted to display the buildings which I thought I filtered, I still see them, just not filtered in the way I want.

    I will see if I can come up with a reduced test case and post that.

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."