clear().draw() not removing rows from table

clear().draw() not removing rows from table

CesarDCesarD Posts: 13Questions: 3Answers: 0

I have the following example: http://live.datatables.net/rezivoma/1/edit
But it can't clear the table when it runs the instruction table.clear().draw()

Am I missing anything? According to the clear() api documentation (https://datatables.net/reference/api/clear()), it's supposed to remove all rows from table...

Thanks in advance.

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin
    Answer ✓

    It will remove all rows on the client-side, but you have:

    serverSide: true,

    DataTables on the client-side doesn't know anything about your server-side data store, so you need to delete the data at the server and then call draw(). The clear() method is useless when server-side processing is enabled.

    I've committed a change to the documentation to state this fact.

    Allan

  • CesarDCesarD Posts: 13Questions: 3Answers: 0

    Oh, ok, cause I have my datatable with deferLoading = 0 to prevent showing any record on the datatable initialization, so I wanted to clear the table when resetting the search criteria, thus I wanted to clear the datatable too. So, there's no way to clear the datatable records in any way if server-side is enabled and deferLoading = 0 ?
    Thanks!

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin
    Answer ✓

    That is correct. If the search criteria changes, then an Ajax request to the server is required for the new information to be displayed.

    Allan

This discussion has been closed.