views:

318

answers:

5

Hi,

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

A: 

Any code you could share would be helpful.

Do you reload your store after insert?

Greg
Thanks for the answer. Actually I did:var grid = Ext.getCmp('grid');grid.getStore().reload();which is a bit useless since this way I can't keep track of what I inserted... I just realized this.
Dajeff
A: 

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 )

Mchl
Yes this seems to be a good way of finding the item. But still how can I get access to the grid, such as let's say grid.GetElement(index) ? I can't find something like that.
Dajeff
See Ext.grid.RowSelectionModel
Mchl
+1  A: 

The code has

store.insert(0, p);

So don't you just highlight row zero immediately after that statement?

Animal
Yes, that s actually the case in the editable grid. But I want a solution that works for other grids. Actually I want to implement this:http://37signals.com/svn/archives/000558.phpI found a solution, as written below (highlight function)
Dajeff
+1  A: 

For info:

You only need to do this (here for row one):

var row = grid.getView().getRow(0); Ext.get(row).highlight();

It's that easy

Dajeff
A: 

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 :)

Extjs Commander