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
saurabh0908
Posts: 2Questions: 0Answers: 0
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]
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]
This discussion has been closed.
Replies
Allan
- Saurabh