How can i write condition in jqgrid colmodel

Jess163

Can u help me. I have the following 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 }
                ],

Below is what I get from 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

I need to compare values. For example: there is the first value in the first cell equal to 60. If 'value'> = 300 or 'value' <= 50, then paint the cell red. Next, the second cell. If value> = 350 or value <= 60. And so with all five meanings.

upd. In my example, the code doesn't work. It does a conditional check on the entire column. And I need for each cell

upd2. see how it works enter image description here

Jess163

Tony Tomov gave the correct answer. Thank you very much, everything worked out and everything works

Below is a link to an example

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" ';
            }
          }
        },

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how can i add a style to "groupingName" using Jqgrid grouping method?

From Dev

jqgrid colModel dynamic Searchoptions

From Dev

How can I wait for a condition?

From Dev

Issue with jqGrid with dynamic colModel while editing rows

From Dev

How do I write this if condition with Jquery?

From Dev

extend jqgrid for colModel edittype

From Dev

What is the use of Index attribute in jqgrid colModel?

From Dev

How I can show the effect of autocomplete with a local array in jqGrid?

From Dev

How can I drag jqgrid edit form properly?

From Dev

How can I detect a jqGrid has been resized?

From Dev

Condtional editable depend on the value in colModel jqGrid

From Dev

How can I get the selected search filter in onCellSelect in free jqGrid?

From Dev

jqGrid - How can i track the speed of local operations

From Dev

how can I write a if condition to break out of for loop in Python

From Dev

ColModel jqgrid different label name

From Dev

How can i edit cells from a table using jQGrid?

From Dev

How can I make a summary using grouping method from jqgrid?

From Dev

Issue with jqGrid with dynamic colModel while editing rows

From Dev

Disable 'disabled' property in jqGrid colmodel

From Dev

Optimize the dynamically created colmodel in jqgrid

From Dev

How can I write a "no two values in [column_list] are equal" condition?

From Dev

In jqgrid, how can I load data by condition?

From Dev

What is the use of Index attribute in jqgrid colModel?

From Dev

How can I write this query

From Dev

How can I set the cell in a jqGrid if the name in colmodel is an integer?

From Dev

Jqgrid text blink based on condition in colmodel

From Dev

how can I write a if condition to break out of for loop in Python

From Dev

How to change colNames and colModel dynamically in jqgrid?

From Dev

How can I write dynamically remove condition in Where clause condition

Related Related

  1. 1

    how can i add a style to "groupingName" using Jqgrid grouping method?

  2. 2

    jqgrid colModel dynamic Searchoptions

  3. 3

    How can I wait for a condition?

  4. 4

    Issue with jqGrid with dynamic colModel while editing rows

  5. 5

    How do I write this if condition with Jquery?

  6. 6

    extend jqgrid for colModel edittype

  7. 7

    What is the use of Index attribute in jqgrid colModel?

  8. 8

    How I can show the effect of autocomplete with a local array in jqGrid?

  9. 9

    How can I drag jqgrid edit form properly?

  10. 10

    How can I detect a jqGrid has been resized?

  11. 11

    Condtional editable depend on the value in colModel jqGrid

  12. 12

    How can I get the selected search filter in onCellSelect in free jqGrid?

  13. 13

    jqGrid - How can i track the speed of local operations

  14. 14

    how can I write a if condition to break out of for loop in Python

  15. 15

    ColModel jqgrid different label name

  16. 16

    How can i edit cells from a table using jQGrid?

  17. 17

    How can I make a summary using grouping method from jqgrid?

  18. 18

    Issue with jqGrid with dynamic colModel while editing rows

  19. 19

    Disable 'disabled' property in jqGrid colmodel

  20. 20

    Optimize the dynamically created colmodel in jqgrid

  21. 21

    How can I write a "no two values in [column_list] are equal" condition?

  22. 22

    In jqgrid, how can I load data by condition?

  23. 23

    What is the use of Index attribute in jqgrid colModel?

  24. 24

    How can I write this query

  25. 25

    How can I set the cell in a jqGrid if the name in colmodel is an integer?

  26. 26

    Jqgrid text blink based on condition in colmodel

  27. 27

    how can I write a if condition to break out of for loop in Python

  28. 28

    How to change colNames and colModel dynamically in jqgrid?

  29. 29

    How can I write dynamically remove condition in Where clause condition

HotTag

Archive