JQgrid:如果填充一列,则更改整行的字体颜色

编程入门 行业动态 更新时间:2024-10-28 12:18:09
本文介绍了JQgrid:如果填充一列,则更改整行的字体颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经阅读了一些职位,但我仍然不能跟随,因为我是新的在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:如果填充一列,则更改整行的字体颜色

本文发布于:2023-07-26 07:09:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1214884.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:则更   字体   颜色   JQgrid   改整行

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!