How to refresh/reload dataTable?

How to refresh/reload dataTable?

pravinkpravink Posts: 16Questions: 0Answers: 0
edited October 2012 in DataTables 1.9
Hello,

I want to reload/refresh the data in dataTable after I click on refresh button.
Currently I am calling the dataTable intialisation function on button click but that's sending the ajax request again and again.
Is there any other way to reload/refresh the dataTable?
Please help, I need this on urgent basis.

Replies

  • pravinkpravink Posts: 16Questions: 0Answers: 0
    Anyone to help me on this? I need this urgently.
  • robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
    There are many threads on this, but here you go:

    This is an example of how I do it in many places. This method recreates a datatable.

    [code]
    var initializeDataTable = function($this, settings) {

    // destroy the existing datatable
    if (settings.$dataTable != undefined) {
    settings.$dataTable = settings.$dataTable..dataTable({ "bDestroy": true });
    }

    // empty the container that wraps the html table
    settings.$dataTableContainer.html("");

    // TODO: append a new html table to the table container

    // create new datatable
    settings.$dataTable = settings.$dataTableContainer.children().first().dataTable(settings.dataTableOptions);
    };
    [/code]
  • pravinkpravink Posts: 16Questions: 0Answers: 0
    Thanks for your Reply Robert!
    Is there any other way to do this? I mean can't we refresh the dataTable without re-initialising it?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Why not just use fnClearTable and fnAddData ? Or for Ajax source data use http://datatables.net/plug-ins/api#fnReloadAjax
  • pravinkpravink Posts: 16Questions: 0Answers: 0
    Thanks Allan! I will try.
This discussion has been closed.