开发者

ExtJs. How to make "Selected Item in the gridPanel" an orphan?

I want to s开发者_StackOverflowomehow 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)


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜