最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to highlight the Extjs grid newly inserted row? - Stack Overflow

programmeradmin6浏览0评论

Any idea how to highlight newly inserted row?

i tried to use store's add event and it gives me the record and record index which last inserted.

but how can i reference it to highlight the grid row?

this is the store.

Ext.create('Ext.data.Store', {
    model   : 'invoice_model',
    storeId : 'invoice_store',
    proxy   : {
        type: 'memory'
    },
    listeners   : {
        add : function(s, r, i){
            console.log(r)  

        }
    }
});

Regards

Any idea how to highlight newly inserted row?

i tried to use store's add event and it gives me the record and record index which last inserted.

but how can i reference it to highlight the grid row?

this is the store.

Ext.create('Ext.data.Store', {
    model   : 'invoice_model',
    storeId : 'invoice_store',
    proxy   : {
        type: 'memory'
    },
    listeners   : {
        add : function(s, r, i){
            console.log(r)  

        }
    }
});

Regards

Share Improve this question asked Sep 11, 2011 at 16:03 Gihan LasitaGihan Lasita 3,05314 gold badges49 silver badges66 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Assuming "i" is the index of the record on the grid (hence, index of the row in the grid):

    Ext.fly(myGrid.getView().getNode(i)).highlight("highlight color", {
            attr: 'color', duration: 5000 
        });

However, if the inserted record is always going to be on the first row, you can just specify the first after a record is added :

    Ext.fly(myGrid.getView().getNode(0)).highlight("highlight color",{ 
              attr: 'color', duration: 5000 
          });

To Highlight the background color of the row, you can add a highlight class to the newly inserted row:

CSS :

   .myHighlight{
       background : your-highlight-color
   }

JS

   Ext.fly(myGrid.getView().getNode(0)).addCls("myHighlight");

and then remove it once your done highlighting :

  Ext.fly(grid.getView().getNode(0)).removeCls("myHighlight");

In your add function, try
Ext.fly(myGrid.getView().getNode(r.getId())).highlight("0000ff", { attr: 'color', duration: 2 });

Change highlight config to your preference

EDIT

Store's add event gives us an array of records that were added. If you want to highlight all of them, iterate over the array and call the above snippet for each record in the array. if you want to highlight particular one, (first or last maybe), get it from the array and call the above snippet. In the above snippet, r refers to a particular record.

发布评论

评论列表(0)

  1. 暂无评论