Change pagelength options with button
Change pagelength options with button
Hello everyone,
Recently I was tasked with getting the excel button to export everything regardless of what the length setting is set on, I know about putting the length to all and then exporting but this is seen as a "workaround" and I was asked to always have the button export all.
Sadly the datatable is set to serverside and changing that would break the website so I can't just use the "page: 'all'," exportoption.
My current idea is to add a button that basically does the "workaround" mentioned above automatically, that is a button that sets the length to show all then presses the export button, sadly I can't seem to be able to change Page length options with a button seperate from the table with js so I need some help.
If you can tell me how to have my excel export button export all regardless of it being serverside or not or a way to have my button do the "workaround" or point me towards the solution somewhere else it would be great.
You can use this page to test https://datatables.net/examples/advanced_init/length_menu.html
Thank you
This question has an accepted answers - jump to answer
Answers
Probably the best option is to use a server side process to export to Excel then download to the client. If you wish to export client side you can create a custom button that sets page length then exports to Excel. Use
page.len()
with a parameter of-1
to fetch all pages. See the last example in thebuttons.buttons.action
docs to see how to call an export button. See if this example helps:http://live.datatables.net/zufunomu/1/edit
Kevin
Thank you, page.len did exactly what I was looking for.