Datatable Destroy() taking too much time.

Datatable Destroy() taking too much time.

shivanagshivanag Posts: 7Questions: 2Answers: 0

In my application i'm loading huge data into data table. And in that datatable i want to search using some search filters.
In that case, what i am doing is i'm destroying the previously loaded table and again loading data by search filters again.

Here the problem is because of huge data like 50k records its taking too much time to destroy data table, and some times page it self not responding.

So is there any other way to handle this ?

Answers

  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin

    Why do you need to destroy the table? Can't you use the clear() and rows.add() methods?

    Allan

  • shivanagshivanag Posts: 7Questions: 2Answers: 0

    No, Actually we need to re intialise that table. because already rows are there.

  • DeepakJenaDeepakJena Posts: 1Questions: 0Answers: 0

    Hi Shivaaaa,
    I got your answer. if u have a large no of records(rows) and u r trying to destroy that, then it will take a no of time due to a bunch of HTML elements. so the easiest way to clear all the html content and then destroy the table.
    for example please check the following code to do so.

    var table=$("#Gridview").dataTable();
    table.html('');
    table.dataTable().fnDestroy();

This discussion has been closed.