Send page number in datatable server side pagination POST

Send page number in datatable server side pagination POST

JasonPolydorJasonPolydor Posts: 1Questions: 1Answers: 0
edited April 2022 in DataTables 1.10

Hello sorry I am new to datatables, I am doing a pagination server side, and would like to send page number in POST
I am using fast-api pagination on server side which needs:
- page
- length

draw: 3
columns[0][data]: 0
columns[0][name]:
columns[0][searchable]: false
columns[0][orderable]: true
columns[0][search][value]:
columns[0][search][regex]: false
columns[1][data]: 1
columns[1][name]:
columns[1][searchable]: true
columns[1][orderable]: true
columns[1][search][value]:
columns[1][search][regex]: false
columns[2][data]: 2
columns[2][name]:
columns[2][searchable]: true
columns[2][orderable]: true
columns[2][search][value]:
columns[2][search][regex]: false
columns[3][data]: 3
columns[3][name]:
columns[3][searchable]: true
columns[3][orderable]: true
columns[3][search][value]:
columns[3][search][regex]: false
columns[4][data]: 4
columns[4][name]:
columns[4][searchable]: true
columns[4][orderable]: true
columns[4][search][value]:
columns[4][search][regex]: false
columns[5][data]: 5
columns[5][name]:
columns[5][searchable]: true
columns[5][orderable]: true
columns[5][search][value]:
columns[5][search][regex]: false
columns[6][data]: 6
columns[6][name]:
columns[6][searchable]: true
columns[6][orderable]: true
columns[6][search][value]:
columns[6][search][regex]: false
columns[7][data]: 7
columns[7][name]:
columns[7][searchable]: true
columns[7][orderable]: false
columns[7][search][value]:
columns[7][search][regex]: false
start: 20
length: 10
search[value]:
search[regex]: false

On my view i have the script below:

$(document).ready(function() { elem = '#user-table'; $(elem).DataTable({ order: [], processing: true, serverSide: true, ajax:{ url: "/get-users-paginations", type: 'POST' }, searching: true, paging: true, info: true, rowId: function ( row ) { return 'tr'+row[0]; }, columnDefs: [ { "targets": [ 0 ], "visible": false, "searchable": false } ] }); });

Thanks

Answers

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    You can use ajax.data to add your data to that being sent to the server. page.info() can be used to get the page number (amongst other things),

    Colin

Sign In or Register to comment.