Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The usage of the function <code>afterInsertRow</code> is not the best way especially if you use <code>gridview:true</code> <a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options" rel="nofollow noreferrer">jqGrid option</a> which is almost always recommended. Look at the <a href="https://stackoverflow.com/questions/3025305/jqgrid-firefox-and-css-text-decoration-problem/3026421#3026421">old answer</a> which do mostly what you need. The schema of the code could be about following</p> <pre><code>$('#list').jqGrid({ //... loadComplete: function() { var ids = $(this).jqGrid("getDataIDs"), l = ids.length, i, rowid, status; for (i = 0; i &lt; l; i++) { rowid = ids[i]; // get data from some column "readStatus" status = $(this).jqGrid("getCell", rowid, "readStatus"); // or get data from some //var rowData = $(this).jqGrid("getRowData', rowid); // now you can set css on the row with some if (status === "error") { $('#' + $.jgrid.jqID(rowid)).addClass('myErrorClass'); } } } }); </code></pre> <p>It looks like "transversing the DOM after grid has completed", but it works quickly as the usage of <code>afterInsertRow</code>.</p> <p><strong>UPDATED</strong>: The answer is relatively old. More recent versions of jqGrid have <code>callattr</code> and <code>rowattr</code> callbacks which can be used to implement the same requirements more effectively. It's important to understand that setting of class on one cell of grid or of the row of grid (see <code>.addClass('myErrorClass')</code> in the code of the answer) follows <a href="https://developers.google.com/speed/articles/reflow" rel="nofollow noreferrer">browser reflow</a> on <em>all elements existing on the page</em>. So one should reduce the number of changing of DOM elements on the page. To do so it's strict recommended to use <code>gridview: true</code> (see <a href="https://stackoverflow.com/a/12519858/315935">the answer</a> for more details). The callbacks <code>callattr</code>, <code>rowattr</code> and custom formatters used together with <code>gridview: true</code> allows to create the full content of grid body <em>at once</em>. So the number of changes on the page will be reduced and the performance will be improved.</p> <p>The column property <code>callattr</code> from <code>colModel</code> can be helpful to set class, style or some other attributes on selected <em>cells</em> of grid. The callback <code>rowattr</code> can help to set class, style or some other attributes on selected <em>rows</em> of grid (exactly like do the above example).</p> <p>I recommend everybody who read the above answer look at <a href="https://stackoverflow.com/a/10531680/315935">the answer</a> which shows how to use <code>rowattr</code>.</p> <p>You can read more about <code>callattr</code> for example in the following answers: <a href="https://stackoverflow.com/a/6048865/315935">this</a>, <a href="https://stackoverflow.com/a/12180842/315935">this</a>, <a href="https://stackoverflow.com/a/9664440/315935">this</a>, <a href="https://stackoverflow.com/a/6509041/315935">this</a>. If you use <code>datatype: "xml"</code> the implementation could be a little more complex: see <a href="https://stackoverflow.com/a/8022860/315935">the answer</a> for details.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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