在ExtJs中更改网格中行的颜色

sai*_*ath 5 grid extjs gridpanel

如何使前五行的Backgroud或文本颜色与接下来的五行不同.例如,前5个黄色,5个橙色,5个黄色,5个橙色等等.

我为网格添加了以下监听器

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

我已经用它来获取第二行的内容为红色.但它不适合我.

Dam*_*ano 8

您可以使用自定义GridView getRowClass方法:

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

然后在您的页面或css中定义自定义行样式类.