JQgrid:如果填充一列,则更改整行的字体颜色 [英] JQgrid : Change entire row's font color if one column is filled
问题描述
我已经阅读了一些职位,但我仍然不能跟随,因为我是新的在jqgrid。
我有一个jqgrid有5列,但1列是空的开始。
在做一些更新后,它会被填充。
我想让JQgrid更改这行的字体颜色,所以如果填充这行将更改字体颜色变为蓝色。
jQuery(#list)。jqGrid({
....
colModel:[
{name:'prob_id',index:'prob_id',hidden:true,width:10},
{name:'Model',index:'Model',width: 100,editable:true,search:true,stype:'text',searchoption:{sopt:['cn']}},
{name:'Serial',index:'Serial',width:80, editable:true,search:true,stype:'text',searchoptions:{sopt:['cn']}},
{name:'Lotno',index:'Lotno',width:50, true,
search:true,
stype:'text',
searchoption:{sopt:['cn']}},
{name:'Detail',index: 'detail',hidden:true,width:70,formatter:myformat}
],
....
function myformat(cellvalue,options,rowObject)
{
if(!empty(cellvalue)){
return'< font color =blue>'+ cellvalue +'< / font>'; //或使用类
} else {
return'< font color =black>'+ cellvalue +'< / font>'; //或使用类别
}
}
我想更改具有详细字段值的所有行的字体颜色
但我得到一个错误:
空未定义
UPDATE
>尝试这样:
我决定将条件移动到:function myformat(cellvalue,options, rowObject)
{
if(cellvalue ==closed){
return'< font color =blue>'+ cellvalue +'< / font& / or use classes
} else {
return'< font color =black>'+ cellvalue +'< / font>'; //或使用类
}
}
它可以工作,但似乎只有一列变成蓝色,整个行都有条件
CLOSED
。解决方案尝试afterInsertRow和setRowData like
afterInsertRow:function(rowid,rowData,rowelem){
var detail = rowData ['详情'];
if(detail ==Closed){
$(this).jqGrid('setRowData',rowid,false,{color:'#000'});
} else {
$(this).jqGrid('setRowData',rowid,false,{color:'#FF0000'});
}
},
删除gridView:true(afterInsertRow如果gridView是真的)
I have read some post but I'm still can't follow due to i'm new in jqgrid. I have a jqgrid which have 5 columns, but 1 column is empty for the beginning. After do some update it would be filled.
I want JQgrid change the font color for this row, so if it is filled this row will be change the font color to blue.
jQuery("#list").jqGrid({ .... colModel :[ {name:'prob_id', index:'prob_id', hidden:true, width:10}, {name:'Model',index:'Model',width:100,editable:true,search:true,stype:'text',searchoption:{sopt:['cn']}}, {name:'Serial', index:'Serial',width:80,editable:true,search:true,stype:'text',searchoptions:{sopt:['cn']}}, {name:'Lotno', index:'Lotno', width:50, editable:true, search:true, stype:'text', searchoption:{sopt:['cn']}}, {name:'Detail', index:'Detail', hidden:true,width:70,formatter:myformat} ], .... function myformat ( cellvalue, options, rowObject ) { if (!empty(cellvalue)){ return '<font color="blue">' + cellvalue + '</font>';//or use classes } else{ return '<font color="black">' + cellvalue + '</font>';//or use classes } }
I would like to change the font color for all rows that have a value for the Detail Field
but I get an error:
empty is not defined
UPDATE
try this way : I'm decided to move the condition to :
function myformat ( cellvalue, options, rowObject ) { if (cellvalue == "closed"){ return '<font color="blue">' + cellvalue + '</font>';//or use classes } else{ return '<font color="black">' + cellvalue + '</font>';//or use classes } }
and it works, but it seems just one column which turn to blue, I want entire row which have condition
CLOSED
.解决方案Try afterInsertRow and setRowData like in the code given below
afterInsertRow: function(rowid, rowData, rowelem) { var detail= rowData['Detail']; if(detail=="Closed"){ $(this).jqGrid('setRowData', rowid, false, { color: '#000' }); }else { $(this).jqGrid('setRowData', rowid, false, { color: '#FF0000' }); } },
Remove gridView:true (afterInsertRow wont work if gridView is true)
这篇关于JQgrid:如果填充一列,则更改整行的字体颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!