title: How to access other row data from a cell's custom formatter in JqGrid
body: <p>I have an <code>XML</code> data source like below,</p>
  
  <pre><code>&lt;root&gt;
      &lt;item priceOri = "100" discount = "10"&gt;&lt;/item&gt;
      &lt;item priceOri = "200" discount = "110"&gt;&lt;/item&gt;
      .
      .
      .
  &lt;/root&gt;
  </code></pre>
  
  <p>And I'm populating those data to a table using JqGrid.
  the code is something like below.</p>
  
  <pre><code>datatype : 'xml',
  colModel: [ 
    ... 
    {name:'priceOri', index:'priceOri', width:60,xmlmap : "[priceOri]", align:"center"},
    {name:'discount', index:'discount', width:60,xmlmap : "[discount]", align:"center"},
    {name:'price', index:'price', width:60,xmlmap : "[price]", align:"center", editable: true, formatter:discountFmatter},
    ...
   ]
  
  xmlReader: {
      root: "root",
      row: "item",
      repeatitems: false
  },  
  </code></pre>
  
  <p>The formatter is like below.</p>
  
  <pre><code>function discountFmatter (cellvalue, options, rowObject)
  {
     var price;
     // do calculation based on other cell values in the same column
     //price = priceOri - discount;
     var new_format_value = price;
     return new_format_value
  }   
  </code></pre>
  
  <p>As in the code I need to access other values in the <code>item</code> tag to calculate the <code>price</code> section. So basically I want to access other cell values in that same row. How can I do that.</p>
  
  <p>I used below code snippets but they resulted as <code>undefined</code></p>
  
  <pre><code>rowObject[0]  // undefined
  rowObject.priceOri //undefined
  </code></pre>
  
  <p>Can anyone show me the steps to achieve this.</p>
  
  <p><strong>UPDATE :</strong> I have the <strong>JqGrid version 4.4.0</strong> of Tony Tomov. Since I'm working on a already developed application I can't change or update that library versions. So I have to do it using the same JqGrid version 4.4.0.</p>
  
  <p>Seems like Oleg's <code>rowObject instanceof Element ? $(rowObject).attr("priceOri") : rowObject.priceOri</code> is working for this requirement.</p>
  
  <p><strong>UPDATE 2 :</strong>  (Because <code>rowObject.rewards</code> wont work in below case)</p>
  
  <p>new XML has below changed format,<br>
         &lt; item priceOri = "100" discount = "10" rewards = "20" >&lt; /item ></p>
  
  <p>So new formatter will be like,</p>
  
  <pre><code>function discountFmatter (cellvalue, options, rowObject)
  {
     var price;
     // do calculation based on other cell values in the same column
     //price = priceOri - discount - rewards;
     var new_format_value = price;
     return new_format_value
  }  
  </code></pre>
  
  <p>Note that I don't display the value <code>rewards</code> in the jQgrid table. So how can I achieve this.</p>
  
  <p>Oleg's answer : <code>In case of usage old jqGrid you will have to add new column rewards. You can use hidden: true property in the column. Free jqGrid allow you to use additionalProperties</code></p>