How to multi filter in one run?

How to multi filter in one run?

ziv@kpmbro.comziv@kpmbro.com Posts: 73Questions: 28Answers: 4
edited January 2018 in General

Hi Allan

I been having some troubles in filtering on a big table.. after debugging it i found out that my code design was not good, because i used to run an ajax call for each filter param (that the user filled), meaning that if the user filled 3 filters my code will do 3 ajax call.
my code :

      $.each(search_array, function(key1, value1) {
          table.columns(key1).search(value1).draw();
      });

is there a way to send an array to the filtering method?, instead of each time to send the key and value..
or any other way to fix it?

Thanks :)

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Don't call draw() inside the loop - call it after:

    $.each(search_array, function(key1, value1) {
        table.columns(key1).search(value1);
    });
    table.draw();
    

    Allan

  • ziv@kpmbro.comziv@kpmbro.com Posts: 73Questions: 28Answers: 4

    Thanks Allan :))) that was it..

This discussion has been closed.