jqGrid单元格内容设置其内容的字体颜色
其中想让(没有填写计划)的状态颜色为红色
colNames:['序号','操作','月份','计划流水号','部门','职务','工号','姓名','考核权重','状态','自评分','考核得分','部门ID','状态ID'],
colModel:[{name:'rowNo',index:'rowNo', align:'center', width:50},
{name:'operateColumn',index:'operateColumn', align:'left', width:100},
{name:'monthCd',index:'monthCd', align:'center', width:55},
{name:'planId',index:'planId', align:'center', width:70},
{name:'groupName',index:'groupName', align:'left', width:80},
{name:'positionName',index:'positionName', align:'left', width:75},
{name:'staffId',index:'staffId', align:'left', width:65},
{name:'staffName',index:'staffName', align:'left', width:65},
{name:'assessWeight',index:'assessWeight', align:'center', width:75, hidden:true},
{name:'statusName',index:'statusName', align:'center', width:120, cellattr: addCellAttr},
{name:'selfScore',index:'selfScore', align:'center', width:55},
{name:'score',index:'score', align:'center', width:55},
//{name:'staffId',index:'staffId', hidden:true},
{name:'groupId',index:'groupId', hidden:true},
{name:'status',index:'status', hidden:true}
],
1.在要改变颜色的一栏加 cellattr:addCellAttr
function addCellAttr(rowId, val, rawObject, cm, rdata) {
if(rawObject.planId == null ){
return "style='color:red'";
}
}
2.添加该方法,if(条件)中写要判断的条件
其中rawObject指的是
当前cell所在的row值,如cell:{序号 = ‘1’,操作 = ‘**’,,。。。。。}