图例如下:
前提:jquery动态加载数据
代码:根据formatter函数来判断数据,符合判断要求的进行背景色标红
$("#Y_J_J_C_CB").datagrid({
onClickRow:hourdataYJForClick1,
columns:[[
{field:'EntName',title:'污染企业名称',width:264,align:'center',sortable:false},
{field:'Time',title:'超标时刻',width:148,align:'center',sortable:false},
{field:'COD',title:'COD(t)',width:68,align:'center',sortable:false,formatter:function(value,row,index){
if(row.IsCOD=='0'){
return '<div style="color:#fff; text-align: center; line-height: 24px; background-color: red;">'+value+'</div>';
}else{
return value;
}
}},
{field:'AD',title:'氨氮(t)',width:68,align:'center',sortable:false,formatter:function(value,row,index){
if(row.IsAD=='0'){
return '<div style="color:#fff; text-align: center;line-height: 24px; background-color: red;">'+value+'</div>';
}else{
return value;
}
}},
{field:'ZL',title:'总磷(t)',width:68,align:'center',sortable:false,formatter:function(value,row,index){
if(row.IsZL=='0'){
return '<div style="color:#fff; text-align: center; line-height: 24px; background-color: red;">'+value+'</div>';
}else{
if(value==''||value==null||value=='0'){
return "---";
}else{
return value;
}
}
}},
{field:'ZD',title:'总氮(t)',width:68,align:'center',sortable:false,formatter:function(value,row,index){
if(row.IsZD=='0'){
return '<div style="color:#fff; text-align: center; line-height: 24px; background-color: red;">'+value+'</div>';
}else{
if(value==''||value==null||value=='0'){
return "---";
}else{
return value;
}
}
}}
]]
});