Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User VDP's Avatar
    Join Date
    Feb 2012
    Location
    Boom, Belgium
    Posts
    87
    Vote Rating
    10
    VDP will become famous soon enough

      0  

    Default [Ext 4.2.0] Iterate over buffered store (store.each) doesn't work

    [Ext 4.2.0] Iterate over buffered store (store.each) doesn't work


    Issue:

    The store.each function doesn't work with buffered stores.

    Code:
        each: function(fn, scope) {
            var data = this.data.items,
                dLen = data.length,
                record, d;
            for (d = 0; d < dLen; d++) {
                record = data[d];
                if (fn.call(scope || record, record, d, dLen) === false) {
                    break;
                }
            }
        }
    the data object on the store has no items array.
    => this.data.items is undefined.

    I expect to be able to loop over the displayed records.

    Used version:

    I'm using Ext 4.2.0.663

    How to test:
    1. http://docs.sencha.com/ext-js/4-2/ex...te-scroll.html use this example or your own infinit scrolling / buffered store example.
    2. run:
    Code:
    Ext.getCmp('gridpanel-1009').getStore().each(function(rec){
        console.log('rec', rec.get('name'));
    });
    => returns TypeError: Cannot read property 'length' of undefined (because items is undefined, data becomes undefined and undefined has no property length)

    Any suggestion on how to loop over the records would be much appreciated!

    Cheers!

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,066
    Vote Rating
    659
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    It's a buffered store, which means it's a sparse data set. How can you loop over it?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha Premium Member
    Join Date
    Mar 2013
    Posts
    29
    Vote Rating
    0
    loumac is on a distinguished road

      0  

    Default store BufferedRenderer

    store BufferedRenderer


    evant - could you expand upon this ? I have the same issue - if you can't loop over the store how do you dynamically update the store's records?

  4. #4
    Sencha User VDP's Avatar
    Join Date
    Feb 2012
    Location
    Boom, Belgium
    Posts
    87
    Vote Rating
    10
    VDP will become famous soon enough

      0  

    Default


    Quote Originally Posted by evant View Post
    It's a buffered store, which means it's a sparse data set. How can you loop over it?
    As I said, I expect to be able to loop over the displayed records. Or the cached records or something...

    The paginated store/grid is also a growing set of data... Isn't the buffered store the same but just keeping a couple pages before and after in memory for quickly showing?

  5. #5
    Sencha Premium Member
    Join Date
    Mar 2013
    Posts
    29
    Vote Rating
    0
    loumac is on a distinguished road

      0  

    Smile iterate over buffered store

    iterate over buffered store


    @VDP
    I managed to figure out that the buffered store data is attached to the grid - the following worked for me to get access to the buffered records to update them

    for (j=01; j<=grid.store.data.length; j++) {
    var data = grid.store.data.map[j].value;
    for (i=0; i<data.length; i++) {
    data[i].data["constantrowselected"]=true;
    }
    }

    hope this helps in your use case

  6. #6
    Sencha User VDP's Avatar
    Join Date
    Feb 2012
    Location
    Boom, Belgium
    Posts
    87
    Vote Rating
    10
    VDP will become famous soon enough

      0  

    Default


    Yup should work Thanx I also was thinking in that direction.

  7. #7
    Sencha User rabelanger's Avatar
    Join Date
    Jan 2010
    Location
    Montreal
    Posts
    15
    Vote Rating
    1
    rabelanger is on a distinguished road

      0  

    Default


    Reading the doc, nothing says anything about limitation to the store even though it is... minimally it should loop over the loaded data or show a warning, not an error.
    rafael