DataTables - server side custom Prev / Next buttons.
DataTables - server side custom Prev / Next buttons.
Hi,
I'm just starting to use DataTables server side with an backend LDAP database.
So far I've got the page loading and displaying the first xx entries based on the 'show entries drop down'
Currently the prev and next buttons appear to work with id but is there any way after first load my backend page can send what values should be used for prev and next ?
My LDAP database doesn't have id entries, so when I';ve done paging in PHP I've used the **cn ** value. What I'm hoping is the backend page can return $prev & $next and those values are then used by the Prev & Next buttons.
Is that possible ?
Thanks
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Thanks for the reply. I'm not going to be able to create a test case as the LDAP server is running locally and is partially proprietary so I've no way to get this online.
I'm only trying to work out how to get Prev & Next to change what they send to the backend script. Are there any examples on that ?
Thanks
The parameters Datatables sends and expects to receive are documented here. You can use either the
ajax.data
option or-optino preXhr
event to alter the parameters sent to the server. You can use wither theajax.dataSrc
orxhr
event convert the received parameters to what server side processing supports.Kevin
Thanks, I'm trying to use ajax.data to send which button, prev or next was pressed.
If I use drawCallback I can detect if the next button is pressed and set variable button to next
But that appears to be triggered once the table is redrawn, So I've tried the same code but using preDrawCallback but that doesn't seem to do anything, when Next is clicked the alert isn't shown.
Is there any way to do this ?
Thanks
The page number can be derived by dividing the
start
parameter by thelength
parameter that is sent to the server. You may need to add one. IS this what you are looking for?If not please provide more details of what you are trying to do.
Kevin
Hi Kevin,
I want to send to my back end script either button = next or ** button = prev** depending on which button was pressed.
Thanks
If there are no other paging buttons, you could do something like this. It's detecting whether the requested page is going forward or backwards. If there are other paging buttons, you can't tell if a specific page was pressed, or the specific "next"/"prev" buttons.
Otherwise, I suspect you'll need to develop your own pagination plug-in that stores the press for you,
Colin
Hi Colin, that does exactly what I need for the Prev / Next buttons. Thanks.
Is there any way to remove the page numbers and only have buttons First, Prev & Next ?
Thanks again
Looks like using
Removes the numbers and added First, Previous, Next, Last
I should be able to work with that.. Thanks
Hi Colin,
The example seems to work showing the Next or Prev in the console, but nothing is passed to my server script. I was expecting to see last in the posted results, but I don't. Any ideas ? Thanks
The
ajax.data
docs show that the first parameter passed into the success function is the data being sent to the server and that it needs to be updated. In the example thedata
variable will need updated to send the paging direction, for example:http://live.datatables.net/xonixujo/70/edit
Kevin
And to tweak Kevin's example here, you can change
pagingType
tosimple
to only show Next/Prev,Colin
I have the paging numbers and data passing working.
Thanks for the help