Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Because you use <code>repeatitems: false</code> format of data then the input data for the grid should be items with named properties which names are the same as the values of <code>name</code> property in <code>colModel</code>. So <code>formatPdfLink</code> function used as <code>formatter</code> will get third parameter <code>rowObject</code> in the same simple format as original data. For example <code>rowObject.pdf_1</code> for example can be used. To access to another column you should just use the value of <code>name</code> property used in <code>colModel</code> for the column.</p> <p><strong>UPDATED</strong>: If you use the same custom formatter multiple times you can need to access properties of <em>the current</em> column. The <code>options</code> parameter will help you here.</p> <pre class="lang-js prettyprint-override"><code>function formatPdfLink(cellValue, options, rowObject) { return "&lt;a href='" + cellValue + "' title='" + options.colModel.name + "' &gt;&lt;img src='../img/PDF_icon.png ' /&gt;&lt;/a&gt; "; } </code></pre> <p>The parameter <code>options</code> contains properties <code>rowId</code>, <code>colModel</code>, <code>gid</code> and <code>pos</code>. <code>this</code> inside of custom formatter are initialized to the DOM of the grid so you can use for example <code>$(this).jqGrid("getGridParam", "parameterName")</code> or just <code>this.p.parameterName</code> to access to other options of jqGrid. The property <code>colModel</code> contains the column definition of the current column only and not the full <code>colModel</code> parameter.</p> <p>For example you can rewrite the code above to set the next from <code>colNames</code> instead of <code>name</code> propertiy in the tooltip:</p> <pre class="lang-js prettyprint-override"><code>function formatPdfLink(cellValue, options, rowObject) { //var colNames = $(this).jqGrid("getGridParam", "colNames"); var colNames = this.p.colNames; return "&lt;a href='" + cellValue + "' title='" + colNames[options.pos] + "' &gt;&lt;img src='../img/PDF_icon.png ' /&gt;&lt;/a&gt; "; } </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