Refresh dataTables data
Refresh dataTables data
Hey.
First of all - I love datatables - it's a great solution!
I have a table with a lot of rows - 500 or so.
It is not working - so I have to use a server side processing.
Furthermore, many tables are autorefreshed every certain interval.
I know that xml islands are bad, but I use it and can't undo that at the time being.
Currently, if I am using Dom to add rows to the table body (tblBody.appendChild(row);) and of course when I use xml islands, DataTables doesn't refresh.
How can I make datatables to "rebuild" when I update table date?
Thenks in advanced.
First of all - I love datatables - it's a great solution!
I have a table with a lot of rows - 500 or so.
It is not working - so I have to use a server side processing.
Furthermore, many tables are autorefreshed every certain interval.
I know that xml islands are bad, but I use it and can't undo that at the time being.
Currently, if I am using Dom to add rows to the table body (tblBody.appendChild(row);) and of course when I use xml islands, DataTables doesn't refresh.
How can I make datatables to "rebuild" when I update table date?
Thenks in advanced.
This discussion has been closed.
Replies
Allan
But - and correct me if I am wrong, this solution supports only json.
I use xml, and even xml islands.
When not using xml islands I am still using xml - parsing the xml element by element, adding each row seperately.
As I was saying = I parse each td and tr element by element and add them to the table (tblBody.appendChild(row);).
I do so for historical reasons and for practical reasons - I need to style each td diffrent, depands on its value.
What can I do?
thank you.
1. Use fnServerData and the Ajax source options to get your XML and then transpose it into a 2D array and give that to DataTables.
2. Use the API methods fnClearTable and fnAddData ( http://datatables.net/api ) to clear the table and then add your new data from the XML (again transposed into a JS array).
Allan
I am having a similar issue. I am using the option 2 approach ( fnClearTable and fnAddData) and it clears the data and adds data to the pagination records, but there is no data displaying in the table.
[code]
function processNewData(xml){
var jData = $( xml );
shipmentSearchResultsTable.fnClearTable();
var searchResultList = $(jData).find('SearchResultList');
var searchResults = searchResultList.children();
searchResults.each(function(){
var plannedDeliveryDate = $(this).find('plannedDeliveryDate').text();
var equipment = $(this).find('equipment').text();
var status = $(this).find('status').text();
shipmentSearchResultsTable.fnAddData( [
plannedDeliveryDate,
equipment,
status
] );
});
}
[/code]
Allan
Please let me know if some one wants the code sample.