Note that there are some explanatory texts on larger screens.

plurals
  1. POjqGrid: change background color of row based on row cell value by column name
    text
    copied!<p>jqGrid has column named Posted. It can be positioned in different positions depending how grid is configured by customer but is always prssent.</p> <p>I need to change background color of rows if Posted column has value True</p> <p>I tried colmodel below but alert(rdata.Posted) displays always undefined.</p> <p>How to change backgound color of row if Posted column in this row has value true ?</p> <p>I looked into lot of Oleg and other solutions for changing background color but they are using hard coded column number.</p> <pre><code>colModel: [ {"cellattr":function(rowId, tv, rawObject, cm, rdata) { if (rdata.Posted) return 'class="jqgrid-readonlycolumn"'; return ''; } ,"label":"Klient","name":"Klient_nimi","classes":null,"hidden":false}, {"label":null,"name":"Posted","editable":true,"width":0, "classes":null,"hidden":true}], ... </code></pre> <p><strong>Update</strong></p> <p>In update2 Oleg recommends to use rowattr. I need to hide inlined delete button and custom post button in actions column also. I'm usijng code below in loadComplete. How to implement this using rowattr ?</p> <pre><code>var LoadCompleteHandler = function () { var iCol = getColumnIndexByName($grid, 'Kinnitatud'), postedDateCol = getColumnIndexByName($grid, 'Kinkuup'), cRows = $grid[0].rows.length, iRow, row, className, isPosted, mycell, mycelldata, i, count, cm = $grid.jqGrid('getGridParam', 'colModel'), l, iActionsCol = getColumnIndexByName($grid, '_actions'); l = cm.length; if (iCol &gt; 0 || postedDateCol &gt; 0) { for (iRow = 0; iRow &lt; cRows; iRow = iRow + 1) { row = $grid[0].rows[iRow]; className = row.className; isPosted = false; if ($.inArray('jqgrow', className.split(' ')) &gt; 0) { // $(row).hasClass('jqgrow') if (iCol &gt; 0) { isPosted = $(row.cells[iCol]).find("&gt;div&gt;input:checked").length &gt; 0; } if (postedDateCol &gt; 0) { mycell = row.cells[postedDateCol]; mycelldata = mycell.textContent || mycell.innerText; isPosted = mycelldata.replace(/^\s+/g, "").replace(/\s+$/g, "") !== ""; } if (isPosted) { if ($.inArray('jqgrid-postedrow', className.split(' ')) === -1) { row.className = className + ' jqgrid-postedrow'; $(row.cells[iActionsCol]).find("&gt;div&gt;div.ui-inline-del").hide(); $(row.cells[iActionsCol]).find("&gt;div&gt;div.ui-inline-post").hide(); } } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload