Mulvihic
Mulvihic

Reputation: 315

Issue jumping to a row in a grid panel

I am using Extjs 4.2. I have a grid panel which has >1000 rows and it has multiselect turned on.

When I click a button I want to select and move to row 20 using the following:

grid.getSelectionModel().select(20, false, true);
grid.getView().getNode(20).scrollIntoView();

This works fine if I am near row 20 but otherwise it correctly selects row 20 but it does not jump to row 20 and I get the error: TypeError: grid.getView(...).getNode(...) is undefined

Any help much appreciated.

Upvotes: 2

Views: 2110

Answers (3)

Mulvihic
Mulvihic

Reputation: 315

Rixo put me on the correct path asking about buffered grids.

I found this example which has it all: http://docs.sencha.com/extjs/4.2.0/extjs-build/examples/grid/buffer-grid.html

This is the line that allows me to jump to row 20:

grid.view.bufferedRenderer.scrollTo(20, true);

Upvotes: 3

V G
V G

Reputation: 19002

The problem is that there is no such Node when you are far away from it, as the GridView simply does not destroys the HTML element because of performance issues. You could use gridView.focusNode(record) for that instead:

var record = gridView.getStore().getById(20);
gridView.focusNode(record);

And after that focus select the record:

grid.getSelectionModel().select(record);

Upvotes: 1

Kishan Reddy
Kishan Reddy

Reputation: 137

First Select your record using:

var rec = grid.store.findRecord('id',rowId);

Select the record using :

grid.getSelectionModel().select(  rec  );

Focus the record using :

grid.getView().focusRow(  ); 

Upvotes: 0

Related Questions