0
votes

I created a fiddle to illustrate what I try to achieve.

https://fiddle.sencha.com/#fiddle/1i8e

On fiddle, there are two grids and a form.

When selecting a row of the first grid, the second grid is filtered (on the server side, this code was not implemented in fiddle).

Something like:

       storeGrid2.load({
            params: {
                'item': id_item
            }
        });

When I press the button in form e get values from second grid store (previously filtered).

This works well.

However, I do not need the second grid as a component in my app.

Is there any way to get the second grid store values (without the grid as component), after being filtered?

Summary: I want when I select the first row of the grid 1, filters the grid2 store (without the grid as component), get this store values (here his my issue) and add the fields to form.

EDITED:

I know that my case is not easy to expose.

Suppose, for example, an app for a restaurant.

The first grid displays the days of the week. The second grid displays the available food ingredients that day. And the form displays the menu.

When the user selects the first grid row with value Monday, the second grid displays potatoes, apples and chicken. The form displays the menu according to these foods ingredients: potato soup, apple pie and fried chicken.

If it is for a restaurant customer, when he select Monday (on first grid) just menu appears, not second grid (customer do not need to know which foods ingredients are available that day, just the menu).

This can be done by hiding the grid.

However, what I was trying to achieve was whether it is possible to directly obtain the data store without a (second) grid component.

Everything happened in the ViewModel/Store layer without existing a view layer (second grid).

When I use store.load() without instantiating a component grid I get the following error: Uncaught TypeError: Cannot read property 'load' of undefined

1
Have you ever heard of Ext.getStore()?Alexander
Yes. I also tried Ext.data.StoreManager.get ('my storeId'); The first problem I have to solve is how to load a store without a grid. storeGrid2.load({ params: { 'item': id_item}}); apparently to run need the grid component. My store is in a viewModel. I want get de values directly from a store widthout a gridjosei
Ok, so basically what you want is to filter a second store based on the value you selected on the first grid, without the need of second grid to represent that data, correct? Just use a chained store to do it - docs.sencha.com/extjs/6.2.0/classic/Ext.data.ChainedStore.htmlGuilherme Lopes
@GuilhermeLopes Nope, that won't work, because the second store has its own data (fetched from the server based on the selection in the first grid). A ChainedStore can only work off data in the source store.Alexander

1 Answers

1
votes

Move the handler function to the viewController.

Create a function called for example onButtonClick. On the button config, add

listeners: {
    click: 'onButtonClick'
}

In the onButtonClick function, get a reference to your store using

var store = this.getViewModel().getStore('mystore1');

then

store.load({
    success: function(records) {
        var name = records[0].get('name');
        ...
    }
});