Posted on 2013-05-04 21:33 
小胡子 阅读(728) 
评论(0)  编辑  收藏  所属分类: 
Ext 
			
			
		 
		Ext.grid.GridPanel可以设置stripeRows: true的属性来实现隔行换颜色的效果,如果你想自定义每行的颜色,那么你可以按照下边地方法来实现:
Ext.ux.GridView=Ext.extend(  
       Ext.grid.GridView,  
       {  
           getRowClass:function(record,index)  
           {  
               if(index%2==0)  
                   return 'red';  
               else  
                  return 'green';  
          }  
       }  
   )  
使用自定义的view 
var grid = new Ext.grid.GridPanel({
        //other code
    store: store,
    view:new Ext.ux.GridView(),
        //other code
});
样式定义:
.red {
     background-color:#FF0000;
}
.green {
     background-color:#00FF00;
}
 通过firebug可以看到,给每行的div添加了自定义的样式 
 原文出自:
http://love4j.iteye.com/blog/516007