title: How to calculate and display column dynamically using Jquery Datatables
body: <p>I am using Jquery Datatables to display my data in form of a table .</p>
  
  <p>I was able to form Table using Jquery Datatables  based on existing  javascript resource .</p>
  
  <p>Right now i have got two columns in the table Name and Price .</p>
  
  <p>I need to display a Third column by name SubPrice which is calculated dynamically  based on Total - Price </p>
  
  <p><a href="http://jsfiddle.net/cv04pp37/5/" rel="nofollow">http://jsfiddle.net/cv04pp37/5/</a></p>
  
  <p>I was trying it this way , but no luck</p>
  
  <pre><code>var table =   $('#kiran').dataTable(
      {
        "order": [
          [1, "desc"]
        ],
        "paging": false,
       "aaData": json,
        "aoColumns": [
          { "mDataProp": "Name" },
          { "mDataProp": "Price" },
            { 
       mRender: function(data, type, row){
         return row.Total - row.Price;
       }
      ]
  
      });
  </code></pre>
  
  <p>Could anybody please help me how to do this </p>
  
  <p>I modified my code to this </p>
  
  <pre><code> var json = [
    {
      "Name": "ONE",
      "Price": "12" ,
      "Total" : "120"
    },
    {
      "Name": "TWO",
      "Price": "100",
       "Total" : "500"
    },
    {
      "Name": "THREE",
      "Price": "42" ,
       "Total" : "300"
    }]
  
  
  
  
       $(function()
        {
       var table =   $('#kiran').dataTable(
          {
            "order": [
              [1, "desc"]
            ],
            "paging": false,
           "aaData": json,
            "aoColumns": [
              { "mDataProp": "Name" },
              { "mDataProp": "Price" },
              { "mDataProp": "My_New_Column_Name" ,
          mRender: function(data, type, row){
          return row.Total - row.Price;
          }
      },
          ]
          })
        })
  </code></pre>
  
  <p><a href="http://jsfiddle.net/cv04pp37/7/" rel="nofollow">http://jsfiddle.net/cv04pp37/7/</a></p>
  
  <p>I am getting this as part of browser console </p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'style' of undefined
  </code></pre>