PDA

View Full Version : Get store's grid



nee
13 Sep 2010, 4:01 AM
Hi all,

Is it possible somehow to get grid from it's store?
I need to clear selections after records are edited.

So I need
record.store.(get grid).getSelectionModel().clearSelections()

Thanks!

laurentParis
13 Sep 2010, 4:27 AM
If you have an ID for your grid, use Ext.getCmp but,if not,
Use event afteredit on Ext.grid.EditorGridPanel (grid)


grid.on('afteredit', afterEdit, grid ); //scope is grid

function afterEdit(e) {
this.getSelectionModel().clearSelections();
};

nee
13 Sep 2010, 4:51 AM
thank you for your reply!

It's no problem to get the grid, I can pass it to my function as an additional parameter together with selected records. But I'm lookig for how to use records to find out what grid they are belong to :).

Animal
13 Sep 2010, 5:00 AM
They don't belong to a grid. A store is independent from any UI. There's no linkage from a Store to any UI object.

Indeed you could have several UI objects using one Store. I do this in several projects which need different "views" of data just like Window's explorer's different views of your files.

13 Sep 2010, 5:01 AM
If you have an ID for your grid, use Ext.getCmp but,if not,
Use event afteredit on Ext.grid.EditorGridPanel (grid)


grid.on('afteredit', afterEdit, grid ); //scope is grid

function afterEdit(e) {
this.getSelectionModel().clearSelections();
};

I would not advocate the use of Ext.getCmp

nee
13 Sep 2010, 5:17 AM
They don't belong to a grid. A store is independent from any UI. There's no linkage from a Store to any UI object.

Indeed you could have several UI objects using one Store. I do this in several projects which need different "views" of data just like Window's explorer's different views of your files.

Animal,
I know that. I'll try to ask in different way: How can I find which UI objects use this store? The store somehow "tells" grid to update after:
record.data.field = 'abc';record.commit();

13 Sep 2010, 5:22 AM
it does that via event handlers, not direct references.

nee
13 Sep 2010, 6:36 AM
Jay,
So the store doesn't know who uses it's data right?

13 Sep 2010, 6:37 AM
correct. It publishes various events (such as loaded) to alert any subscribers to update their view. Look at DataView.js and GridView.js and it will make sense.