0

I have a panel that dynamically I can add as items a Grid, Chart, etc.

Any of those "Widgets" (grid, chart, etc.) have a store.

My panel has a "refresh tool" that onRefreshClick I want to reload the "Widget" store.

In my main Controller I have:

onRefreshClick: function (tool) {
        console.log('refresh widget store');

        var me = this,
            panel = tool.up('panel');

        // here I want to access the store of the child item.

        // So I can do:
        /*

            widgetStore.load();

        */

    },

I won't know if it's widget is a grid, chart, dataview, etc? So I just have to get the store of the child component.

Any clue on how can I achieve this?

VAAA
  • 14,531
  • 28
  • 130
  • 253

2 Answers2

1
Ext.each(panel.query(), function(widget){
   if(!Ext.isEmpty(widget.getStore()) widget.getStore().load();
})
Jairo R. Flores
  • 724
  • 4
  • 11
0

I don't think you can use ComponentQuery to retrieve a store, so I'd do something like:

for (var i = 0; i < panel.items.items.length; i++) {
    try {
        store = panel.items.items[i].getStore();
        if (store != null) break;
    } catch (err) {
        //the component you looped through does not have a store...
    }
}

if (store != null)
    store.load();

Not beautiful, but it should work. Now, if sometimes your component are nested maybe you could refactor this into a recursive function (a function that calls itself)

Francis Ducharme
  • 4,848
  • 6
  • 43
  • 81