我如何在 jqgrid colmodel 中编写条件

How can i write condition in jqgrid colmodel

你能帮帮我吗?我有以下 colmodel:

colNames: ["Name","Value", "upper limit", "lower limit", "stock"],
            colModel: [
                { name: 'Num', index:'num', align:"center", sortable:false,width: 40, resizable:false },
                { name: 'Value', index:'Value', align:"center", width: 70,
                    cellattr: function (rowId, cellValue, rawObject, cm, rdata) {
                        // {
                        //     if (rawObject[1] >= 300 || rawObject[1] <= 50) {
                        //         var colorText = 'style="font-weight: bold;font-size: 24px;+colorText"';
                        //     } else {
                        //         var colorText = 'style="font-weight: bold;font-size: 24px;color:red"';
                        //     };  return(colorText);}},
                        console.log (rawObject[1])
                    }},

                {name:'upper', index:'upper', align:"center", width: 25, resizable:false,editable:true,
                    cellattr: function(rowId, val, rawObject){return 'style="font-size: 15px;"';}},
                {name:'lower', index:'lower', align:"center", width: 25, resizable:false, editable:true,
                    cellattr: function(rowId, val, rawObject){return 'style="font-size: 15px;"';}},
                { name: 'stock', index:'stock', align:"center", sortable:false,width: 40, resizable:false }
                ],

下面是我从 get-data.php.

得到的
$array = array(
array("1","$f1rst", "300","50"),//: Закладочный ствол
array("2","$second","350","60"),//: Клетьевой ствол
array("3","$three","120","20"),//: Портал
array("4","$four","200","20"),//: Скиповой ствол
array("5","$five","200","0"));//: ЦВС


//var_dump($array);
if (empty($array)) {
    echo '["Нет данных"]';
}
else {echo json_encode($array);}

index.php example

我需要比较值。例如:第一个单元格中的第一个值等于 60。如果 'value'> = 300 或 'value' <= 50,则将单元格涂成红色。 接下来,第二个细胞。 If value> = 350 or value <= 60. 因此具有所有五个含义。

更新。 在我的示例中,代码不起作用。它对整个列进行条件检查。我需要每个单元格

upd2。 看看它怎么运作

Tony Tomov 给出了正确答案。非常感谢,一切顺利,一切顺利

下面是一个link的例子

example

 {label: 'Название', name: 'Num', index: 'num', align: "center", sortable: false, width: 40, resizable: false},
        {
          label: 'Значение', name: 'Value', index: 'Value', align: "center", width: 70,
          cellattr: function (rowId, cellValue, rawObject, cm, rdata) {
            if (rdata["Num"] === '1' && (rdata['Value'] >= 300 || rdata['Value'] <= 50)) {
              return ' class="class1" ';
            } else if (rdata["Num"] === '2' && (rdata['Value'] >= 350 || rdata['Value'] <= 60)) {
              return ' class="class1" ';
            } else if (rdata["Num"] === '3' && (rdata['Value'] >= 120 || rdata['Value'] <= 20)) {
              return ' class="class1" ';
            } else if (rdata["Num"] === '4' && (rdata['Value'] >= 200 || rdata['Value'] <= 20 || isNaN(rdata['Value']))) {
              return ' class="class1" ';
            } else if (rdata["Num"] === '5' && (rdata['Value'] >= 200 || rdata['Value'] <= 0)) {
              return ' class="class1" ';
            }
          }
        },