Reputation: 101
I want to create such a grid: http://www.sencha.com/deploy/dev/examples/grid/edit-grid.html
Actually I already did, but I want to highlight the last inserted row of my grid (in extjs this is the function highlight(), which does a yellowfade on the element).
I didn't actually succeed in doing this... my problem is that I can't get the row I just inserted, and thus obviously I can't highlight it. Any clues?
Thanks in advance
Upvotes: 3
Views: 10610
Reputation: 101
You only need to do this (here for row number one):
var row = grid.getView().getRow(0);
Ext.get(row).highlight();
It's that easy.
Upvotes: 7
Reputation: 18980
This would go inside of your add/create button event. The code this.getSelectionModel().select(0);
will highlight the first row since we inserted into position 0, we are selecting position 0. This code works with ExtJS 4.2.0.
var rec = Ext.create('App.model.GridModel', {
id: '123',
name: 'ABC'
});
this.store.insert(0, rec);
this.getSelectionModel().select(0);
Upvotes: 0
Reputation: 1988
yes sorry for answering too late, use Ext.grid.RowSelectionModel and than use selectLastRow function u can easily will be able to point it out :)
Upvotes: 1
Reputation:
The code has
store.insert(0, p);
So don't you just highlight row zero immediately after that statement?
Upvotes: 1
Reputation: 62387
Ext.data.store has a add listener which is passed an index at which records were inserted
add : ( Store this, Ext.data.Record[] records, Number index )
Upvotes: 0