Unable to add new column based on result of ajax call - Getting error datatable requested unknow par

Unable to add new column based on result of ajax call - Getting error datatable requested unknow par

saurabh0908saurabh0908 Posts: 2Questions: 0Answers: 0
edited September 2012 in General
I am new to datatables. I have a requirement of adding column based on the computation from result of my ajax call using jquery. I tried below approach but get error " datatable Requested unknown parameter from the data source for row" . Is this the right approach for this kind of requirement. I'll really appreciate your help in this regard.


This is how table structure looks:
[code]



Time1
Time2
Elapsed Time





[/code]

Here is sample output from my ajax call:
[code]
[{
"time1": 12345,
"time2": 56789
},
{
"time1": 2000,
"time2": 3000
}]

[/code]
This is what I am trying with datatables
[code]
$('#result').dataTable({
"sAjaxSource": "http://" + hostname + ":" + port + api,
"sAjaxDataProp": "",
"iDisplayLength": 25,
"bRetrieve": true,
"sPaginationType": "full_numbers",
"aoColumns": [{
"mDataProp": "time1"
},
{
"mDataProp": "time2"
},
{
"mRender": function(data, type, row) {

return (row.time2 - row.time1);
},
"mDataProp": null
}
]
});

[/code]

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Seems to work just fine for me: http://live.datatables.net/axurel/edit#javascript,html . What version of DataTables are you using? If not 1.9.4 then I'd suggest updating.

    Allan
  • saurabh0908saurabh0908 Posts: 2Questions: 0Answers: 0
    edited September 2012
    I was using some 1.8 version. In 1.9.4 it works like a charm. Thanks a lot Allan.

    - Saurabh
This discussion has been closed.