2

I am trying to iterate through data of ExtReact store to get the data from the store using .getData().

Subsequently, when I try to iterate through the items, I don't get any results for a single item. It's like it is empty.

Here is the result of data.items when I console.log the whole array:

enter image description here

However, when I go through this array using forEach I am getting nothing.

This is the code of forEach loop:

if(userShortCutData.items !== undefined){
    console.log(userShortCutData.items);
    userShortCutData.items.forEach(function(item){
        console.log(item); //nothing is consol.log-ed;
        console.log(item.data); //nothing is consol.log-ed;
        console.log(item._user); //nothing is consol.log-ed;
    });
}
RobC
  • 22,977
  • 20
  • 73
  • 80

1 Answers1

3

To get the underlying list of records as an array:

store.getRange().forEach(r => {
    console.log(r.id);
});

To use the built in store method:

store.each(r => {
    console.log(r.id);
});

You can use a load or refresh listener (depending on what you need) on the store to wait until data has been processed:

store.on('refresh', () => {
    // do the magic();
});
Evan Trimboli
  • 29,900
  • 6
  • 45
  • 66