How server side processing with DataTable works?
How server side processing with DataTable works?
Debugger code (debug.datatables.net):
http://live.datatables.net/nirosoko/3/edit
Description of problem:
I'm pretty new to nodejs and expressjs. I am trying to use datatables with serverside processing. I have a large number of records and I only pull 10 records from the database and display them on the screen. With the pagination method, when I go to a forward page, I pull and show the other 10 records. But I am not sure how to use the search area. While these are ready in client side processing, we need to add queries ourselves in server side processing. But the data I show on the screen comes from more than one table. I'm not sure how the searching area should work, whether this is how server side processing should work, if I'm doing the right thing. I will be grateful if you could help me.
I want the search area to work only when enter is pressed. But when I type something in the search section and press enter, first /search and then /getAllDevice part is called and the page is not refreshed. How can I prevent this?
Answers
When you are using server-side processing with DataTables, the filtering must be done at the server-side. DataTables submits a
search
object which contains information about the current search which you need to use. The parameters are documented here.If you didn't want to write your own server-side processing script, you could consider using our NodeJS libraries.
Allan
Hi Allan, thank you for your interest. Did you see my example? I'm not sure I did correct implementation. I have a problem like this:
When I type something in the search section and press enter, first /search and then /getAllDevice part is called and the page is not refreshed. When I switch between pages, I want /getAllDevice part to work, and when I search, I want /search part to work. How can I achieve this?
Just to confirm my understanding - you want to change the request URL based on if there is a search string or not?
If so, you would need to use
ajax
as a function and have anif
statement inside it which checks if there is a search term or not.Also
is wrong in your code. From the manual:
Allan