Restoring emptyTable text and hiding search when a table is emptied.

Restoring emptyTable text and hiding search when a table is emptied.

lilbiscuitlilbiscuit Posts: 2Questions: 1Answers: 0

I am clearing out a table with $('#data-table').DataTable().clear().draw(); but when I do the table still displays the search box, and does NOT display the emptyTable string.

My expected behavior is that when the above function is run the resulting empty table would be displayed exactly as it is when first loaded, where the search box is hidden and the emptyTable string is displayed.

I am pulling data remotely, and the user can clear out the table, thus the need to show the original empty table in its proper format. I thought if I executed draw() on an empty table you'd get my desired result. How is this accomplished?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    The message is appearing as expected here - http://live.datatables.net/dimurane/1/edit . Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Regarding the search box being hidden - we don't hide the search box before records are present, that must be your custom code, so you would need to implement that same code there too.

    Cheers,

    Colin

  • lilbiscuitlilbiscuit Posts: 2Questions: 1Answers: 0

    The config searching: false will hide the search box. I then destroy and rebuild the DataTable when the user selects criteria to fetch data and don't hide the search box then. I have it all working now...your example helped. Thanks!

Sign In or Register to comment.