When deleting a row, the data is still available from search and YADCF filters if no page refresh

When deleting a row, the data is still available from search and YADCF filters if no page refresh

lenamtllenamtl Posts: 265Questions: 65Answers: 1

When deleting a row, the row disappear from the table but info still appear datatable search and Yadcf filter
and if I do a search with delete info the deleted row will be visible in the table (because no page refresh)

I'm deleting the row using PHP and Ajax
The ajax in on a seperate JS file.
I'm not using server side datatable version

success: function(response) {
    $("#"+rowId).remove();
},

I have tried with no luck to add one of these to reset or draw the table

//yadcf.exResetAllFilters(table16);
//$("#files-list").DataTable().draw();

The only way I have found to get it the deleted data cleared is to reload the page.
Thanks

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    Answer ✓

    You are removing the html but you are not removing the row from the dataset used to build your table so when you redraw, it just puts it right back.

    it should be something like

    success: function(response) {
    $("#files-list").DataTable().rows($("#"+rowId)).remove()

    yadcf.exResetAllFilters(table16);

    $("#files-list").DataTable().draw();
    }

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1

    Hi thanks it's working perfectly!
    I endup using this

    success: function(response) {
    $("#files-list").DataTable().rows($("#"+rowId)).remove()
    $("#files-list").DataTable().draw();
    }
    
  • lenamtllenamtl Posts: 265Questions: 65Answers: 1

    I'm just updating this as yadcf.exResetAllFilters(table16); was not working ...

    I'm setting the datatables search and column search empty instead of using Yadcf reset
    This way the localstorage get updated correctly (otherwise when the yadcf search value item get deleted the table result was not updated and show nothing found.

    success: function(response) {
        $("#files-list").DataTable().rows($("#"+rowId)).remove()
        $("#files-list").DataTable().search("").columns().search("").draw();
    },
    
This discussion has been closed.