admin管理员组

文章数量:1327884

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.

本文标签: javascriptHow to highlight the Extjs grid newly inserted rowStack Overflow