Table won't reload

Table won't reload

TheNerdy97TheNerdy97 Posts: 23Questions: 5Answers: 1

I have this function that unchecks all checked boxes until here it works flawlessly, but when it should reload the data table, it won't work and checkbox values are still shown on the table.

this is the code

    $('#reset').click(function(){
      const filters = document.getElementsByName("Characters_Filter");
      for (let i = 0; i < filters.length; i++) {
        if (filters[i].type = "checkbox") {
          filters[i].checked = false;

      $('#accountsTable').DataTable().draw();

  
        }
      }
      });

this is a live example
https://jsfiddle.net/TheNerdy97/vpaw347s/64/

I know that dataSrc isn't an ajax but it's for the sake of example.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 16,782Questions: 25Answers: 3,972
    Answer ✓

    Using draw() causes Datatables to update the table's display by applying the current sorting, searching and paging. This is all client side unless you are using server side processing - which your test case doesn't appear to have. If you want to refresh the data from the server use ajax.reload() instead.

    If this doesn't help the please provide the steps to show the issue in your test case.

    Kevin

  • TheNerdy97TheNerdy97 Posts: 23Questions: 5Answers: 1

    I was going in the wrong way, instead of reloading the table, I was supposed to do:

     table.fnfilter('', 3) 
    

    solved the problem

Sign In or Register to comment.