开发者

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

Actual开发者_运维百科ly 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


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.


The code has

store.insert(0, p);

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


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


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 )


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜