How can I optimize the individual column searching ?

How can I optimize the individual column searching ?

correiaccorreiac Posts: 2Questions: 1Answers: 0

Hello everyone !
When I search by column using datatables, each character's addition a new request is made. So each of these queries is waiting for the previous one to be complete.
The process is very long, so how can I optimize this ?
Thanks

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Add a debounce. If you've added code to do the column based search, you can add a javascript debounce to limit how often it is triggered.

    Allan

  • correiaccorreiac Posts: 2Questions: 1Answers: 0

    Thanks for your answer !

    Add a debounce. If you've added code to do the column based search, you can add a javascript debounce to limit how often it is triggered.

    I'm using DataTables from php code, so for the ajax method which is called when i search in one column i can't really handle it. At least i don't know how...
    Have you any idea ? I'm using sg datatables bundle and symfony 2.

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    I can't really comment on the symfony aspect as I haven't used that framework, but the debounce I suggested and in the post I linked to, is a client-side (i.e. Javascript) function.

    Basically you need to put the column().search() method inside a debounce function so it isn't called too frequently.

    Allan

This discussion has been closed.