Compute a value from the javasript source dynamically and display the value using Jquery Datatable

Compute a value from the javasript source dynamically and display the value using Jquery Datatable

krn1231krn1231 Posts: 9Questions: 4Answers: 0

Is it possible to display an extra column under Jquery Datatables by name SubPrice and add sorting to it dynamically which is based on javascript source input values Total - Price in JSON ??

This is my javascript source

var json = [
  {
    "Name": "ONE",
    "Price": "12" ,
    "Total" : "120"
  },
  {
    "Name": "TWO",
    "Price": "100",
     "Total" : "500"
  },
  {
    "Name": "THREE",
    "Price": "42" ,
     "Total" : "300"
  }]




 $(function()
  {
    //$("#kiran").dataTable();
    //displayData();
 var table =   $('#kiran').dataTable(
    {
      "order": [
        [1, "desc"]
      ],
      "paging": false,
     "aaData": json,
      "aoColumns": [
        { "mDataProp": "Name" },
        { "mDataProp": "Price" }
    ]

    });

setInterval (function test() {
         table.fnDraw();
       }, 3000);

  })

http://jsfiddle.net/cv04pp37/1/

This discussion has been closed.