Datatables.net - directly set data for redraw
Datatables.net - directly set data for redraw
Hello.
Is it possible to directly set the data for datatables.net?
[code]
CompetitionList = $('#tblTournaments').dataTable({
"oLanguage": {
"sUrl": "/ClientHandlers/DataTableHandler.ashx?methodName=LoadLanguage"
},
"sDom": 'Rrt<"toolbar"<"inner"<"left"li><"right"p><"clear">>>',
"sPaginationType": "full_numbers",
"bFilter": false,
"bAutoWidth": false,
"aaData": data,
"aoColumns": [
{ "sTitle": "Date","sWidth": "100px", "sClass": "header", "fnRender": function (obj) { return gbDate.toShortDateString(cc.textToDateTime(obj.aData["Date"])) } },
{ "sTitle": "Name", "sClass": "header", "mDataProp": "Name" },
{ "sTitle": "Status", "sType": "status-bar", "sWidth": "180px", "sClass": "header", "fnRender": function (obj) { return "" + obj.aData["Progress"] + "%" } }
]
});
[/code]
thats my datatable. what i would like to do is have a function "refresh" the table.
The way i imagine this is to_
-clear the table (working)
-feed it new data (not working)
-redraw(working)
how would i go about directly setting the data while preserving all the other stuff?
impossible like this?
please note that my data is comming from an external jquery.ajax function, thats why i cant do it "the normal way".
(unless i overlooked something :))
Is it possible to directly set the data for datatables.net?
[code]
CompetitionList = $('#tblTournaments').dataTable({
"oLanguage": {
"sUrl": "/ClientHandlers/DataTableHandler.ashx?methodName=LoadLanguage"
},
"sDom": 'Rrt<"toolbar"<"inner"<"left"li><"right"p><"clear">>>',
"sPaginationType": "full_numbers",
"bFilter": false,
"bAutoWidth": false,
"aaData": data,
"aoColumns": [
{ "sTitle": "Date","sWidth": "100px", "sClass": "header", "fnRender": function (obj) { return gbDate.toShortDateString(cc.textToDateTime(obj.aData["Date"])) } },
{ "sTitle": "Name", "sClass": "header", "mDataProp": "Name" },
{ "sTitle": "Status", "sType": "status-bar", "sWidth": "180px", "sClass": "header", "fnRender": function (obj) { return "" + obj.aData["Progress"] + "%" } }
]
});
[/code]
thats my datatable. what i would like to do is have a function "refresh" the table.
The way i imagine this is to_
-clear the table (working)
-feed it new data (not working)
-redraw(working)
how would i go about directly setting the data while preserving all the other stuff?
impossible like this?
please note that my data is comming from an external jquery.ajax function, thats why i cant do it "the normal way".
(unless i overlooked something :))
This discussion has been closed.
Replies
Ofcourse it was, after simply trying the most logical (which didnt work first time, something else in the code broke it i guess)
this simply worked:
[code]
CompetitionList.fnClearTable();
CompetitionList.fnAddData(data);
CompetitionList.fnDraw();
[/code]
I would expect that to work (and indeed was what I was going to suggest until I saw your own reply :-) ). fnAddData should just add data in the original format that you give the table. What does data look like? Also you shouldn't need to do an fnDraw after fnAddData, since fnAddData will do a draw for you.
Allan