0
votes

I am using Datatables with server side processing to display data. I have around 10000 rows of data which I would like to limit to make it more readable.

I would like to display only 50 rows of data in the datatable.

$('#dataTable3').dataTable({ 
        "sAjaxSource": "user_data.php",
        "sPaginationType":"full_numbers",
        "bProcessing": true,
        "bPaginate":true,
        "iDisplayLength": 20,       
        "aoColumns": [      
        { mData: 'sno' } ,
        { mData: 'dob' } ,
        { mData: 'fullname' },
        { mData: 'email'}]      
    });

The server side PHP script limits the number of rows to 50 as shown :

SELECT * FROM users order by id desc limit 50

Now, the issue is if I want to search for a particular user, it is searching from the 50 rows of the Datatable. I would like to search on the server side as well. Any idea how to do it ?

1
set serverSide:true. In doing so, all control is turned over to the server.Bindrid
Have you tried anything else?henrique romao

1 Answers

0
votes

There are some rules you have to consider when you are using server-side processing with DataTables.

On every load datatables executes, it sends some parameters to your server and it expects some others back to identify the data, quantity and filters to apply.

You need to read those on the request sent by datatables and apply them on you filters and data fetching on you database.

You can check how datatables sends the request in this image.

As mentioned by @Bindrid, you can check the detailed definition of those parameters here.

There is a good tutorial here and here that you can check how to do that using PHP.
And, of course, there is also the example on the datatables documentation.