Quantcast
Viewing all articles
Browse latest Browse all 82143

Possible to re-load data table content from the HTML?

Thanks for this brilliant plugin. I have a question about updating the data in a data table. Using MVC, I populate the table, and data table reads the data from HTML the first time. I have a need to sometimes change the data in the table, and would prefer to do that with MVC as well (@Ajax.BeginForm and partial view for the table body). This would make the code more consistent (and would help with e.g date formatting).

I’ve found out that I can refresh the data through ajax in the following manner:

$.ajax({

}).success(function (data, textStatus, jqXHR) {
oTable = $('#example-table).dataTable();
oTable.fnClearTable();
data.forEach(function(entry) {
oTable.fnAddData([”content of first column”, ”content of second column”, ….]);
}
});

It would still be great if there were a function to make a clean start-over from the DOM with the new data, but I haven't found one. Is there any such function?

Viewing all articles
Browse latest Browse all 82143

Trending Articles