EasyUI datagrid 动态修改行背景色或单元格背景

修改行背景色


$('#dg').datagrid({  
    rowStyler: function(index,row) {
        	if (row.id == -1) {
        		return ""
        	}
        	
        	if (row.status == '2') {
                return 'background-color:#E2EFD9;';
            } 
   
         	return 'background-color:#FFF2CC;';
            
        }
}); 

修改单元格背景色


{
               field:'status',
               title:'状态',
               halign:'center',
               align:'center',
               width:80,
               editor:{
                   type:'combobox',
                   options: {
                       data: jobStatus,
                       valueField: "value",
                       textField: "text",
                       editable: false,
                       panelHeight:'auto'
                   }
                       
               },
               formatter:function(value, row){
                   if (Util.isEmpty(value)) {
                       return "";
                   } else {
                       for (var i = 0; i < jobStatus.length; i++) { 
                           if (jobStatus[i].value == value) {
                               return jobStatus[i].text;
                           }
                       }
                   }
               },
               styler: function(value,row,index){
                   if (value=='2') {
                       return 'background-color:#E2EFD9;';
                   } 
                   if (value=='1') {
                	   return 'background-color:#FFF2CC;';
                   }
                   return "";
               }
          }

你可能感兴趣的:(EasyUI datagrid 动态修改行背景色或单元格背景)