3 ms·
I had to do a version of this for myself a few weeks back in conjunction with datatables. We actually also use form elements in the table as well, which I had t
by ebiester 13y ago
I had to do a version of this for myself a few weeks back in conjunction with datatables. We actually also use form elements in the table as well, which I had to handle as special cases. We'd then send the JSON back to the server, which would generate an Excel file.
Why not just send back to the server instead? First, sending the JSON back turned out to be faster than rerunning the query. Second, datatables has a full text search option which made things simpler for our case.
(Datatables has an export plugin, but it uses flash and only generates thinly-veiled CSV.)
So there's a use case for something like this.
- bdg 13y agoHave you thought about sending the HTML of that data back instead of computing the JSON encoding? Your server side could actually parse the DOM and possibly preserve things like fonts/styles when loading into excel (I know how giddy managers get when their auto-generated reports have styles).
- ebiester 13y agoIn our case, we didn't want to send it all back, and we had our own style to enact on the server side. Sending back the HTML is perfectly fine (albeit a little larger) but as this is JSON, you could easily send back the style to the server if you so wanted.