searchBuilder disappears after a table destroy and recreate
searchBuilder disappears after a table destroy and recreate
Description of problem:
I am saving the state of my datatable and I'm trying to reset the state back to the original (column visibility, ordering and searchBuilder) using a button. My approach is to destroy, clear and then rebuild the datatable. It all works fine and the column visibility, column ordering and data are reset and reloaded, however the searchBuilder disappears. If I use the searchBuilder button, once clicked the container appears empty. If it's prepended to the datatable, it completely disappears.
Here is the code I use for the reset:
Link to test case:
dt = $('#mytable').DataTable(....) //table initialization including searchBuilder: true
//
..reset button code:
//
dt.clear();
dt.destroy();
newdt = createDataTable(); // function to create the datatable
newdt.state.clear();
newdt.searchBuilder.container().prependTo(newdt.table().container());
newdt.searchBuilder.rebuild({});
newdt.clear().draw();
newdt.ajax.reload();
Thanks.
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin