1
votes

I want to somehow save "current selected record" in my GridPanel, then i want to delete GridPanel, create it again and set "current selected record" back.

What is the best, or common way to do this?

PS: or you can answer this, how to select record in GridPanel by record's "id" (for example)

1
why delete the entire gridPanel? Would it not be more effective to store the record in a variable, clear the store and then repopulate the gridStore with that single record? It would probably also require less code.StevenMcD
well.. it's just my app requre to do so... i want to delete grid in one place, then create it at another place... but when i do so, i losing my "current selected record"..obenjiro
so busicly my app requre to "move" gridPanel from one place to another..obenjiro

1 Answers

4
votes

The best method I can think of is storing the record in a variable by calling:

var record = gridPanel.getSelectionModel().getSelected();

Recreate your grid whenever it is needed then, assuming the new gridStore structure bound to the new grid is the same as the previous gridStore, you can call:

gridStore.add(record);

That should then add the record to your new store and thus to your new gridPanel. Hope it helps and I hope I understood your question correctly.

EDIT: You can also select the records by calling: gridPanel.store.getById("id");

EDIT2:

So to select a row in a gridPanel based on a record's ID you need to do 2 things.

1) Get the index of the record on the gridPanel:

var recordIndex = gridPanel.store.getIndexById("id");

2) Select the record on the gridPanel using the index:

gridPanel.getSelectionModel().selectRow(recordIndex);