title: jqGrid - How to calculated column to jqgrid?
body: <p>I am working on an ASP MVC 2 application.It has a jqGrid and data in the grid is populated from the JSON object returned by the controller. My grid has 3 columns 'UnitNo','Area' and 'Rate per sqm'. These column values are retrived from the database. Now what i need is to add a 4th column 'Unit Price' which is calculated by multiplying 'Area' and 'Rate per sqm'. How can i accomplish this? Is there any way to add a calculated column in jqGrid? Or can i do the calculation in my controller and add it as a new element of row cell?</p>
  
  <p>Here is my controller code:</p>
  
  <pre><code>public JsonResult GetERVList()
      {
          var ervRep=new ERVRepository();
          IList&lt;ERVMaster&gt; list = ervRep.ListERVData();
          int pageSize = 50;
          int totalRecords = list.Count();
          var totalPages = (int)Math.Ceiling(totalRecords / (float)pageSize);
          var jsonData = new
          {
              total = totalPages,
              pageSize,
              records = totalRecords,
              rows = (from ervdata in list
                      select new
                      {
                          i = ervdata.Id,
                          cell = new[]
                              {
                                  ervdata.UnitNo,
                                  ervdata.Area, 
                                  ervdata.RatePerSQM
  
  
                              }
  
                      }).ToArray()
          };
          return Json(jsonData, JsonRequestBehavior.AllowGet);
  </code></pre>
  
  <p>} </p>
  
  <p>and my jqGrid code is like this</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  jQuery(document).ready(function () {
      jQuery("#list").jqGrid({
          url: '/ERV/GetERVList/',
          datatype: 'json',
          mtype: 'GET',
          colNames: ['Unit', 'Area', 'Rate per SQM'],
          colModel: [ { name: 'UnitNo', index: 'UnitNo' },
                      { name: 'Area', index: 'Area' },
                      { name: 'RatePerSQM', index: 'RatePerSQM' }],
          pager: jQuery('#pager'),
          rowNum: 10,
          rowList: [5, 10, 20, 50],
          sortname: 'Id',
          sortorder: "Id",
          viewrecords: true,
          caption: 'My first grid'
      });
  });
  </code></pre>
  
  <p></p>
  
  <p>Thanks in advance,
  Ancy</p>