Results 1 to 4 of 4

Thread: Difficulty removing records from store

  1. #1
    Ext JS Premium Member
    Join Date
    Nov 2011
    Posts
    8
    Vote Rating
    0
      0  

    Default Answered: Difficulty removing records from store

    I have a store from which I need to remove certain records before I display the data. The store is loaded, and I can iterate over the set, but I am having trouble calling remove() on the appropriate records. If I read the set into a variable, I can make the necessary deletions, but the iteration is really slow.

    Code:
    var s = this.getStore('myStore');
                s.each(function(record) {
                     s.remove(record);
                     changed = true;
                        
                });
    ... and if I chain the methods, I can't seem to access the record.
    Code:
    this.getStore('myStore').each(function(record) {
                        this.remove(record);
                });
    Am I missing something simple or am I going about this the wrong way? Thanks for your help.

  2. well, there are 2 options:

    1) put all records you want to remove into an array and call store.remove() once with that array. this way all the view listeners (dom sizing etc.) will only get fired once.

    2) for me it looks like you actually want to filter the store. so take a look at:
    http://docs.sencha.com/ext-js/4-0/#!...ethod-filterBy

  3. #2
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,200
    Answers
    3988
    Vote Rating
    1454
      0  

    Default

    Is the store loaded?
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #3
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751
    Answers
    130
    Vote Rating
    129
      0  

    Default

    well, there are 2 options:

    1) put all records you want to remove into an array and call store.remove() once with that array. this way all the view listeners (dom sizing etc.) will only get fired once.

    2) for me it looks like you actually want to filter the store. so take a look at:
    http://docs.sencha.com/ext-js/4-0/#!...ethod-filterBy
    Best regards
    Tobias Uhlig

  5. #4
    Ext JS Premium Member
    Join Date
    Nov 2011
    Posts
    8
    Vote Rating
    0
      0  

    Default

    Tobias,

    I think you are right. The filterBy() method is much faster than each(). Do you know why that is?

    In any case, thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •