Buttons - Export data when using server-side ajax processing
Buttons - Export data when using server-side ajax processing
cramblda
Posts: 15Questions: 2Answers: 1
I'm looking for information regarding exporting when server-side ajax processing is employed.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
To be more specific, in the old "Table Tools" examples it appeared you could specify an ajax url to get the export data. When I look over the new "Buttons" configuration docs, I'm not seeing a similar option. Can I retrieve the export data from an ajax route?
So is there no way to do this currently?
Did you ever figure this out? I'm working on the same issue - I moved from using locally loaded data to server side and cannot figure out a simple solution using the new buttons. Thanks!
No. I haven't worked on it since posting my question. I was hoping to get some confirmation that there was some type of facility built in to DataTables for this behavior before starting any work, but I can't find any indication that there is native support yet.
Have you googled it? Theres 3 or 4 threads on this exact issue..
In short.. if you have so few rows that you can export all of them, it voids the reason behind using serverSide processing
@jLinux, appreciate your response.
Yes, I googled the issue several different ways when I originally posted the question and found 0 results that weren't for the old TableTools API. My question was posted Sept 21, chronologically before each and every one of the thread links you included in your followup response.
I wouldn't have bothered with the setup time for server side if its use didn't make a substantial improvement in performance for my situation. As such, removing server side is not a reasonable option for this situation. However, the number of records is no where near the limit for a reasonable export.
It sounds as though writing my own server side export is the best option in this case.
For others that may stumble across this thread, server side export of all data is not available with the Buttons API. At this point, if you want to use server side and have export support for all data, you will need to write your own export process.
No no.. it is possible, just not recommended.
@jLinux - thank you for your responses. Like @cramblda I have a situation where loading the data client-side takes a significant amount of time (5000+ rows with 25 columns [side note: I have argued to clean the data up but sales guys want it all in one place so that is what I have to deal with]) especially in Firefox which does full table re-draws on every cell. The actual query is quite quick but drawing the initial table is what takes up the time and I'm not experienced enough with front end to speed it up much more and I have to insert the data into a wordpress site, altogether a not very pleasant situation.
Yes I saw those comments. Loading all the data into the DOM client side, before exporting the data, isn't reasonable for performance in my situation. My best path forward is to keep the server side configuration for DataTables, and then create my own button that servers up an export file from the server, bypassing the need to load any data into the DOM.
I had this same issue and i worked around it by extending the excel export button and providing my own implementation of the export to excel. Granted I copied most of the hard stuff from the buttons.flash.js file. Here is my implementation, granted you will need to modify it to suit your needs. What you need to know.
Feel free to use this if it helps you and please let me know if you find any issues with it.
I see
$.royalWebMethod
, does that mean you're using ASP.NET?That kinda seems like an issue... @allan, would you know if its possible to accomplish this with an asynchronous request?
Yes, I am using ASP.NET with page level WebMethod's to retrieve the data.
EEK!
Well glad you got your issue resolved.
This is correct - there is no callback or promise in the default export Buttons to write data to. You could do it by using the ZeroClipboard API and writing your own custom button, but I can't emphasis enough how much I think using client-side creation of files with server-side processing is a bad idea. You loose all benefit of server-side processing and introduce the client-side limitations on file exporting.
Allan
Hi everyone!
Is there an out-of-box solution now for the server-side data export?
Or we still have retired TableTools and custom scripts?
No change that I'm aware of.
The gist of the problem is most people switch to server side because there is too much data to load in the client all at once. As such, sending all the data to the client for export purposes (when your using server side) would cause the same performance issue. Due to this consideration, no builtin server side export API hook is built in.
However, someone did say you could override the page number in the URL of the button to 0 (zero), and then it will export all the data, instead of just the specific page the user is on.
Okay. Thank for the information.
The tool is great anyway. It saved so much time with it's functionality.
My solution for this is the folllowing:
I decided to privide user ability to show all rows if required and called the button "Export visible rows".
These are my colums
But I think the usual upper limit of exported data would be 1000 rows.
Even if it was 5000 I think the modern machines will handle that normally, but haven't tested that.