Dajeff
Dajeff

Reputation: 101

ExtJs / Sencha : how to highlight a grid row after insert?

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

Answers (5)

Dajeff
Dajeff

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

JustBeingHelpful
JustBeingHelpful

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

Amit Sharma
Amit Sharma

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

user72863
user72863

Reputation:

The code has

store.insert(0, p);

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

Upvotes: 1

Mchl
Mchl

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

Related Questions