change color of rows in grid in ExtJs
Asked Answered
Q

2

5

How to get the Backgroud or text colour of first five rows to be different from the next five rows. For example, First 5 Yellow,5 Orange,5 Yellow,5 Orange,and so on..

I added following listener for the grid

listeners: {
    viewready: function(g) {
        g.getView().getRow(1).style.color="#f30";
    }
} 

I've used this to get the contents in second line in red.But it's not working for me.

Quadroon answered 6/3, 2012 at 10:24 Comment(1)
Code of what you've tried so far?Celandine
H
10

You can use a custom GridView getRowClass method:

var mygrid = new Ext.grid.GridPanel({
   viewConfig: {
      getRowClass: function(record, index, rowParams)
      {
         return (Math.floor(index / 5.0) % 2 == 0) ? 'rowClass1' : 'rowClass2';
      }
   }
})

Then define in your page or in your css the custom row style classes.

Heger answered 6/3, 2012 at 15:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.