tgreen
tgreen

Reputation: 1926

Extjs grid selection after store.load has incorrect data

In ExtJS 4.2 I have a grid with records with a remote load. I select a row in the grid and update that in the database.I am updating a record in the database and reloading the store with store.load(). After this occurs I can pause in debugger and check the store and it does indeed have the correct values. The same record is still selected however the following code:

var selectedRecords = grid.getSelectionModel().getSelection();

Is not getting the updated records. If I deselect and reselect it the record is refreshed but without doing so it still has the old values. Is there a way to refresh it.

I see a lot of posts about getting the rows to stay selected upon load, but that is not a problem for me it seems to be doing that on its own.

Upvotes: 3

Views: 1864

Answers (2)

inQstvJS
inQstvJS

Reputation: 303

It seems to be a bug with the underlying the Selection Model. The 'selected' mixed collection does not get updated as Ext.selection.Model extends Ext.util.Observable and will be updated only when some event happens related to grid selection. If you do not want to deselect and then then select manually, or even register a callback on the store load, then try the following as workaround,

var selectionArr = grid.selModel.selected; selectionArr.replace(selectionArr.keys[0],grid.getStore().getById(selectionArr.keys[0]));

Now try,

var selectedRecords = grid.selModel.getSelection();

Should work fine.

Upvotes: 4

Kutty
Kutty

Reputation: 722

Try to refresh the grid store after updating the value.

Ext.getCmp('myGridID').getView().refresh()

Upvotes: 0

Related Questions