Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Probably you need to use <a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:colmodel_options" rel="noreferrer">classes</a> property for the corresponding column.</p> <p>I am not sure that it's what you need because you wrote about <code>FormElement</code> class existing in <em>form</em>. In the case you have to use <a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing#events" rel="noreferrer">beforeShowForm</a> callback of the form editing for example to add class to the input field of the corresponding field of the edit form. The id of the fields in the form are the same as the <code>name</code> property of the corresponding column of <code>colModel</code>.</p> <p>If you really need to add class attribute to the cells of one column you have one more possibility: defining <code>cellattr</code> callback for the column of <code>colModel</code>. The way could be practical if you need to add the class <em>not for all cells of the column</em>. You can test some conditions based on the row content and set the class only if the condition take place. For example the usage of <code>classes:'ui-state-error-text ui-state-error'</code> will set corresponding two classes (<code>ui-state-error-text</code> and <code>ui-state-error</code>) on <em>all</em> cells on the column. On the other side the callback function</p> <pre class="lang-js prettyprint-override"><code>cellattr: function(rowId, val, rawObject) { if (parseFloat(val) &gt; 200) { return " class='ui-state-error-text ui-state-error'"; } } </code></pre> <p>allows you to set the class only if the cell value is higher as 200. I don't used <code>rawObject</code> in the above callback and so one could remove the optional parameter. I added it in the callback only to remind you that one can use the parameter to access to the values from <em>another</em> columns of the row. So you can implement even more complex scenarios in <code>cellattr</code>.</p> <p>As the result one can get the grid like on the following picture:</p> <p><img src="https://i.stack.imgur.com/j8Bq2.png" alt="enter image description here"></p> <p><strong>UPDATED</strong>: If you need to add <code>class</code> on the input field of the edit forme you can additionally use<code>dataInit</code> callback of <a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules#editoptions" rel="noreferrer">editoptions</a>. In the case the usage will be very simple. You can do for example the following:</p> <pre class="lang-js prettyprint-override"><code>editoptions: { dataInit: function (domElem) { $(domElem).addClass("ui-state-highlight"); } } </code></pre> <p>As the result you will get the edit form like</p> <p><img src="https://i.stack.imgur.com/sKIWo.png" alt="enter image description here"></p> <p>The demo you can find <a href="http://www.ok-soft-gmbh.com/jqGrid/addclasstocolumn.htm" rel="noreferrer">here</a>.</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. 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