我可以使用jqgrid的oncellselect事件根据单元格内容将文本颜色更改为蓝色吗

Can I change the text color to blue based on cell content with oncellselect event of jqgrid?

本文关键字:颜色 文本 蓝色 单元格 jqgrid 可以使 oncellselect 事件 我可以      更新时间:2023-09-26

//(例如:如果单元格内容为"YES"或"NO"……则如果为"YES",则其颜色必须为蓝色)我已经在打开新页面的位置提供了"YES(是)"的链接。。。。我试过了,但点击"是"的链接后,文本颜色变为蓝色。

<style>
.clickData{
    text-align: center;
    text-decoration: underline;
    -moz-text-decoration-color: red; 
    text-decoration-color: red;
    font: bold;
    cursor: pointer;
    color:blue;
    weightfont:bold;
}
</style>


onCellSelect: function(rowid, icol, cellcontent, e) {
if (icol === 10 && cellcontent !== "N/A") {
var ro_code = $('#rep').jqGrid('getCell', rowid, 'RO_CODE');
var insp_no = $('#rep').jqGrid('getCell', rowid, 'Inspection No');
var insp_date = $('#rep').jqGrid('getCell', rowid, 'Inspection Date');
InspComplete(ro_code, insp_no, insp_date);
tr = $("#rep")[0].rows.namedItem(rowid), 
td = tr.cells[icol];
 $(td).addClass("clickData").css("color", "blue");
} else {
tr = $("#rep")[0].rows.namedItem(rowid), 
td = tr.cells[icol];
$(td).removeClass("clickData");
}

<script>
function InspComplete(ro_code, insp_no, insp_date) {
var popupWindow = null;
popupWindow = window.open('./Inspection/Summary/completeInsp.jsp?prepage=true&rep_type=VIEW&ro_code=' + ro_code + '&insp_no=' + insp_no + '&insp_date=' + insp_date, '_blank', 'scrollbars=1,width=1300,height=600');
popupWindow.focus();
}
</script>

我不确定我是否完全理解您的需求,但我认为您需要在colModel中使用cellattr回调。查看答案、答案和这个