Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use the <a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3aevents" rel="nofollow">onSelectRow</a> or the <a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3aevents" rel="nofollow">onCellSelect</a> event defined for the <code>jqGrid</code> to write a function, that adds or removes an image in the column data</p> <pre><code>onSelectRow: function(rowId){ //code to add image and remove from all other rows var ids = $("#grid").jqGrid('getDataIDs'); var ic = ""; for(var i=0;i &lt; ids.length;i++){ jQuery("#grid").jqGrid('setRowData',rowId,{colName:ic}); } ic = "&lt;img src='path/images/buttons/icon.gif'/&gt;"; jQuery("#grid").jqGrid('setRowData',rowId,{colName:ic}); }, </code></pre> <p><br></p> <pre><code>onCellSelect: function(id, iCol, cellContent, e){ //code to add image and remove from all other rows var ids = $("#grid").jqGrid('getDataIDs'); var ic = ""; for(var i=0;i &lt; ids.length;i++){ jQuery("#grid").jqGrid('setRowData',rowId,{colName:ic}); } ic = "&lt;img src='path/images/buttons/icon.gif'/&gt;"; jQuery("#grid").jqGrid('setRowData',id,{colName:ic}); } </code></pre> <p><strong>UPDATED :</strong></p> <p>As @Oleg suggest the other event that can be used without much of an overhead is : <br><a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3aevents#list_of_events" rel="nofollow">beforeSelectRow</a>: <br></p> <pre><code>beforeSelectRow: function(id, e){ //code to add image and remove from all other rows var gsr = jQuery("#grid").jqGrid('getGridParam','selrow'); var ic = ""; jQuery("#grid").jqGrid('setRowData',gsr,{colName:ic}); ic = "&lt;img src='path/images/buttons/icon.gif'/&gt;"; jQuery("#grid").jqGrid('setRowData',id,{colName:ic}); } </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