Customizing page length with AJAX-ServerSide Processing

Customizing page length with AJAX-ServerSide Processing

archiesuaarchiesua Posts: 1Questions: 1Answers: 0
edited November 2020 in Free community support

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
Hi I am trying to customize the page length based on the example shown on this site as follows, "lengthMenu":[[10, 25, 50, -1],[10, 25, 50, "All"]], it works fine for all integers except for the -1 value. The length is send to the php script which process the POST request as follows:
$row_per_page = $_POST['length'];
$statement = getLearnersQualificationsAndCourses($search_query, $col_name, $col_sort_order, $row, $row_per_page);

I can understand the issue because I am passing in the -1 length to a function which used the value to build the query whereas from reading the information this -1 cancels the pagination which I interpret as on the front-end.

My question is, how to allow this customization of the length with ServerProcessing?

Thanks for your help and looking forward to hearing from you.

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    That's an initialisation option, so you can't change it once the table is initialised. Because of that, you would need to query the server first, get the lengths you want, and then initialise the table with those values.

    This is an example that Kevin did for a different thread. Here the columns are being created dynamically, you could use a similar approach but for the page lengths,

    Colin

This discussion has been closed.