3
votes

I have a grid panel used for searching items. It starts out empty but it's configured store loads whenever a user triggers a nearby searchfield.

I'm using grid.getSelectionModel().select(0) to select the first row when it loads. But this doesn't enable key navigation with the arrow keys afterwards. If I perform a mousedown on a row then the arrow key navigation will work.

I would like to just automatically select the first record and have the arrow key navigation enabled.

I've tried focusing on the grid, the gridview and also the first row with grid.view.focusRow(0) and I've tried all of these before and after calling select(0). None of these give me key navigation. Any ideas?

This is using 4.1b2

1

1 Answers

3
votes

ExtJs4 have special singleton class for focus management. It calls with:

Ext.FocusManager.enable({focusFrame: true});

Just put this after Ext loading, and you with see highlighted component which have focus in present. So, you was very close to make it working, I tested and it works in my application

grid.getView().focus();
grid.getSelectionModel().select(0);

p.s. Please be sure that you have more than 0 records in your store.