Title: Export data grid to ... html table Post by: korenanzo on August 02, 2016, 02:07:27 AM Hi,
I need to export the datagrid to a html table; well actually not the whole datagrid but what its showed by the current view. I mean: the user could move or hide columns, order them , add totals and subtotals; moreover the could have a custom data view, with colors and images ... well, I'd like to have this view exported in html (and pdf as well). Any way to do this? Thanks, RIc Title: Re: Export data grid to ... html table Post by: jarry on August 02, 2016, 08:17:04 AM It is more suitable to export data from the remote server. No built-in method to export the datagrid but you can call 'getRows' method to get the current rows and then build the html table manually.
Title: Re: Export data grid to ... html table Post by: korenanzo on August 02, 2016, 08:37:56 AM the problem is that the user should print (pdf) the data as seen in the current view, not as known by the server.
for the same reason I cannot use getRows(), 'cause it sports only de data, not the view Title: Re: Export data grid to ... html table Post by: jarry on August 02, 2016, 08:37:55 PM You can use 3rd library to export to pdf. Here is the example that uses the jspdf library and autotable plugin to export the datagrid to PDF.
http://code.reloado.com/uqiwur/edit#preview Title: Re: Export data grid to ... html table Post by: korenanzo on August 03, 2016, 12:12:00 AM I am trying to help myself :)
I've modified an old piece of code by stworty, I think, and made this: Code:
this maintains the features of every cell (colors, formats, column order, hidden columns) BUT if using data grid-scrollview and the table is long,it sports only the current page, so I am missing something... RIc Title: Re: Export data grid to ... html table Post by: jarry on August 03, 2016, 06:22:25 PM Here is the simple implement of 'toHtml' method that can export all the rows.
Code: (function($){ Title: Re: Export data grid to ... html table Post by: korenanzo on August 03, 2016, 11:55:40 PM Thank you carry,
one more thing: your code shows all the columns even the ones hidden; how to avoid their presence? Thanks, Ric Title: Re: Export data grid to ... html table Post by: jarry on August 04, 2016, 08:33:44 AM Please look at the 'toHtml' method in previous post. The hidden columns aren't exported.
Title: Re: Export data grid to ... html table Post by: korenanzo on August 05, 2016, 12:52:31 AM It seems ok now, thank you :)
|