View Full Version : Keep grid selection even when record has been modified

18 Jan 2013, 7:59 AM
Hi guys,

Hope some of you can shed some light to my problem:

I have grid and when some row is selected the row information is loaded into an edit panel outside the grid. In this panel user can modify the record and save his changes. This will reload my grid and here come my issue:
I need to have the very same record selected in the grid after reloading.

why is that complicated:
(1) record id is Ext stuff, so I can't store the id and select it again on reloading, 'cause id will change;
(2) also, the grid can be ordered by any column and columns have information that might be modified in the edit panel, so, even keeping the same order parameter, the order might change as well and thus I could not store row id;
(3) moreover, what if the change in the record modify the page the record will be? How to control and set the correct page?

Until now, I just have the row id stored like below:

// my extended GridPanel

initComponent: function() {
selectedRecords: [],
reselect: function(){return false;},

// lots of stuff

this.getStore().on('beforeload', this.rememberSelection, this);
this.getView().on('refresh', this.refreshSelection, this);

rememberSelection: function(selModel, selectedRecords) {
this.selectedRecords = this.getSelectionModel().getSelections();

for (var i = 0; i < this.selectedRecords.length; i++) {
this.selectedRecords[i] = this.store.indexOf(this.selectedRecords[i]);

this.reselect = function() {
for (var i = 0; i < this.selectedRecords.length; i++) {

refreshSelection: function() {
// other stuff

Any help/hint will be very usefull.


18 Jan 2013, 11:04 AM
Guess I realize the problem can't be solved in client side.

With the pagination I don't have all the items in the client context to be able to select one of them by some key ... I meant ... after record has been changed I can't guarantee it will be available in the next response. And if it is how could I know with only one query in which page should I put it ???

1 Apr 2013, 3:16 AM
Hi Santosh,

I am facing the same problem. Did you find any solution to this.


1 Apr 2013, 3:44 AM
Yes ... Kind of ;-)

I did a pagination stored procedure and current page information has been added to my json.

The procedure receives a sysref cursor built with the select statement and the rowid from the record I want to find as parameters.

So, in the first page load rowid is null and the procedure returns the first page.

Any time the selected record is being changed and the refresh/reload of the grid is called the rowid is sent in the Ajax request. Then, the stored procedure do the pagination search until it finds the page where current record belongs to. If not found, first page is returned. When found, all records and current page are returned (it is a pipelined oracle procedure).

Finally, in the front end, the paging toolbar is set to current page. I'd already have the total size info in my json so pagination goes smoothly.

Hope that helps!