How to use server side scripting with Datatables
How to use server side scripting with Datatables
Hello
I have a Jave EE application using Servlets. Im currently using datatables for displaying the data, however there are large no. of records that need to be shown on the jsp (>30k records). The time taken to fetch these 30k records (from SQL) in a single go by the controller and converting it to datatables on jsp is quite considertable.
Hence i would cut down on the time. I read there is the option to use server side with datatables, however the example given is of php.
Can someone help how it can be easily achieved with Servlets and java?
This question has an accepted answers - jump to answer
Answers
The documentation for server-side processing with DataTables is available here. I'm afraid I'm not very experienced with Java myself, so there are no examples of server-side processing for DataTables.
Allan
Allan
I managed to write code in Java and its working now, the data is being pulled correctly using server side.
However now the filter is not working correctly on the column.
JS snippet
Earlier (before changing to server side) the same code was working and the data would be seen filtered only if Column(2) had 'Abc' text.
Can you help to resolve?
Move the initial search into
initComplete
. You have to keep in mind that when using Ajax loaded data the initialisation of the DataTable is async.Allan
Allan
Can you guide me to an example where a specific column can be obtained easily in initComplete to perform serach and then draw.
The example i have seen states to user this.api().columns() and then iterate over the columns until the desired column is reached and then perform search.
should be all you need based on the above.
Allan
Tried the below, but it does add the filer. (There are no errors when seen from Developer Tools).
Does or doesn't? If it doesn't work, could you linke to a page showing the issue to I can try to help debug it please?
Thanks,
Allan
Sry for the typo. It does not work. Filter is not added
View Plunker
Sry for the typo. It does not work. Filter is not added
View Plunker
-
That means that all filtering would be done at the server-side. In the example you linked to it is always just loading static data with no filtering being performed which is why it isn't working.
Allan