How to customize default params(draw, start and length) when using DT with server side processing ?

How to customize default params(draw, start and length) when using DT with server side processing ?

AnkushKhuranaAnkushKhurana Posts: 4Questions: 1Answers: 0

Hi

I am new to DataTable and JQuery JavaScript world.

I am using data table with server side processing. From the manual(https://datatables.net/manual/server-side) I understood that by default data table sends a few params to the server (draw, start, length). My question is -

is it possible to customize that request sent to server ? mainly do we need to handle draw parameter in the service and send it back ? Start field will it always be 0 and does it have any default value ?

Service has a field limit which is like length (which is the number of records to be returned), offset (from which index to start sending the results, e.g if offset is 10 and limit is 25, then server will return records from 11 to 35).

Please help me understand how to customize the request data and how can I map these fields properly ?

Thanks in advance :)

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    Answer ✓

    You can use ajax.data to add and modify parameters.

    Allan

  • AnkushKhuranaAnkushKhurana Posts: 4Questions: 1Answers: 0

    Thanks for the reply. I went through the ajax.data option. Just one more question

    Do we need to handle draw parameter in server side and send it back ? is it mandatory parameter or optional ?

  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    Answer ✓

    As of 1.10 it is mandatory. You can technically get away without it, but I would very much suggest you don't.

    The next major update to DataTables will probably do away with it (I've thought of a better way :-) ).

    Allan

  • AnkushKhuranaAnkushKhurana Posts: 4Questions: 1Answers: 0

    Thanks for the reply..it's working now..now i have one more issue. I tried exporting the results but it exports only the available records in the table at that time (Say 10 or 25) not the all records.

    Is it possible to export whole table records with server side processing ?

  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    Answer ✓

    See this FAQ.

  • AnkushKhuranaAnkushKhurana Posts: 4Questions: 1Answers: 0

    thanks for the info. It's really helpful.

This discussion has been closed.