Three identical server side ajax requests when using SearchBuilder

Three identical server side ajax requests when using SearchBuilder

supermindsupermind Posts: 16Questions: 2Answers: 0

Link to test case:
http://live.datatables.net/gihuqawi/1/edit

When enabling SearchBuilder (Q in 'dom' property) DataTables makes three identical ajax requests to the server. Without QueryBuilder, only one request is made. I found this problem debugging why my initial table reload is so slow on huge datasets. With smaller data sets where database don't choak this is not an issue.

Any ideas how to fix this?

Replies

  • sandysandy Posts: 805Questions: 0Answers: 216

    Hi @supermind ,

    Thanks for pointing this out. When using client side processing these are all certainly required, but it may be possible to remove some of them when using server-side processing. I've raised an issue internally (DD-2429 for my reference) and will report back here when there is an update.

    Thanks,
    Sandy

  • supermindsupermind Posts: 16Questions: 2Answers: 0

    Great! I hope you'll find a way to minimize request count (to one) :smile: to avoid unnecessary traffic between client and backend server.

  • sandysandy Posts: 805Questions: 0Answers: 216

    Hi @supermind ,

    That should be the issue fixed now as you can see at this example. This will be available in the next SearchBuilder release which we hope will be in the next few weeks. Until then you can access the fix from the nightly builds.

    Thanks,
    Sandy

  • sandysandy Posts: 805Questions: 0Answers: 216

    Just to note here for anyone else who stumbles across this thread...

    The examples above do not apply any filtering to the table, they only demonstrate the number of requests that SB makes when using SB and stateSave. The live site doesn't have a script that is set up to allow for SB SSP, so this one has been used instead purely to demonstrate that issue.

    Thanks,
    Sandy

  • supermindsupermind Posts: 16Questions: 2Answers: 0

    Thanks for the fix! I referenced to the nightly version of SearchBuilder and tt worked well to certain point and I saw only one request sent to server.

    However, when state is saved, no "searchBuilder": {} element is found in the JSON and I think this causes error when loading the state back again. Error is "dataTables.searchBuilder.js:3193 Uncaught TypeError: Cannot read properties of null (reading 'searchBuilder') at HTMLTableElement.<anonymous> (dataTables.searchBuilder.js:3193:75)".

    This is my initial finding and I will dig deeper. Just to let you know that I faced problems with this build while not making other changes in my code so I think something might be broken in the nightly build.

  • supermindsupermind Posts: 16Questions: 2Answers: 0

    @sandy I can confirm that something went wrong with your fix. If you delete saved state from browsers LocalStorage and refresh the page, you'll see that data is not loaded and JS error is thrown. You can use your own live demo to see this: http://live.datatables.net/davocade/1/edit .

  • colincolin Posts: 13,295Questions: 0Answers: 2,272

    Thanks for that - I've tagged it for Sandy to look at when he's next in,

    Colin

  • sandysandy Posts: 805Questions: 0Answers: 216

    Hi @supermind ,

    However, when state is saved, no "searchBuilder": {} element is found in the JSON and I think this causes error when loading the state back again.

    Thanks for pointing that out. I've raised an issue internally (DD-2434 for my reference) and will report back here when we make a fix.

    Thanks,
    Sandy

  • sandysandy Posts: 805Questions: 0Answers: 216

    Hi @supermind ,

    That should be the issue fixed now as you can see at this example. This will be available in the next SearchBuilder release which we hope will be in the next few weeks. Until then you can access the fix from the nightly builds.

    Thanks,
    Sandy

  • supermindsupermind Posts: 16Questions: 2Answers: 0

    Super! Thank you for the fix once again! :smile: I tested this within my own app and it seems to work.

Sign In or Register to comment.