EasyUI Forum

General Category => General Discussion => Topic started by: jega on May 04, 2018, 07:14:04 AM



Title: [SOLVED AS AN EXTENSION] Printing - Convert to csv, xls, pdf from datagrid
Post by: jega on May 04, 2018, 07:14:04 AM
HI.

I'm a very happy user of easyui. Today i got an advertising of jqwidget, and was looking at it. EasyUI and jqWidget can do many of the same things but also some different things.

One thing that i find very nice is the feature in jqxgrid. Data export and data printing.

I think that a lot of people will love these features.

Any chance for that in easyui ?? Or when ?? ;-)

Regards
Jesper


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: Alfred on May 04, 2018, 07:31:26 AM
It would be nice if Easyui could integrate the same. I am using MPDF for PDF, PHPExcel for Excel and for chart, HighChart. So I depend a lot on third party library.


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: jarry on May 06, 2018, 01:32:39 AM
The exporting extension can be downloaded from https://www.jeasyui.com/extension/downloads/datagrid-export.zip


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: jega on May 06, 2018, 01:04:05 PM
Hi Jarry

Thanks for the code

Printing works fine, but export to excel fails.

Error description
SCRIPT122: Det dataområde, der blev sendt til et systemkald, er for småt.
(In English: The dataarea which is send to a systemcall, is too small)

Error in line 59
alink[0].click();

Tried different things, but can't get it to work

Jesper



Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: jarry on May 06, 2018, 06:56:40 PM
The IE has the url length limit. Please re-download the 'datagrid-export.js' file to fix this issue.


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: jega on May 06, 2018, 10:48:23 PM
Hi Jarry

This works.

BUT. Then i had a problem with Danish charset.

Added <meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8"> before <head> and i now have Danish in the excel file

What about toCSV and toPDF ;-)


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: thecyberzone on May 07, 2018, 01:58:00 AM
And what about Convert2PDF ???


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: jarry on May 08, 2018, 01:05:04 AM
Call the 'toArray' method to get the array data and use the pdfmake library to create the pdf.
Code:
var body = $('#dg').datagrid('toArray');
var docDefinition = {
    content: [{
        table: {
            headerRows: 1,
            widths: ['*','*','*','*','auto','*'],
            body: body
        }
    }]
};
pdfMake.createPdf(docDefinition).open();


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: jega on May 08, 2018, 11:51:38 PM
Hi Jarry

Have no method toArray ???


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: jarry on May 09, 2018, 06:14:23 PM
Please download a newer version from from https://www.jeasyui.com/extension/downloads/datagrid-export.zip


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: proceno72 on May 09, 2018, 11:39:31 PM
Please download a newer version from from https://www.jeasyui.com/extension/downloads/datagrid-export.zip
Wow, I've been waiting for a while this kind of extension. When it will be "official" and then documented? As I wrote on ather post, it could be a good practice on extensions site pages to show a changelog, a version number or at least a "last modified date". It's very difficult for me realize if I'm using the latest version of any extension


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: Pierre on May 09, 2018, 11:42:16 PM
Jarry, this is awesome, thank you for your work.  :)


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: jega on May 10, 2018, 01:22:24 AM
Downloaded the new version.

On calling var body = $('#dg').datagrid('toArray'); i get this error

SCRIPT438: The object does not support the feature or method 'toArray'
jquery.easyui.min.js (11055,1)

jquery.easyui.min.js is version 1.5.5.1

Same problem on two different IIS servers


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: jarry on May 10, 2018, 02:52:01 AM
Please look at this example http://code.reloado.com/ulosin4/2/edit#preview


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: jega on May 10, 2018, 05:38:47 AM
Hi Jarry

The sample works fine yes, but i have the same code, and mine fails.

What i found was, that i do not have the function toArray() in datagrid-export.js

When i download the newest zip file, i still get an zip file with an old version. Maybe a cache problem. Downloaded the file from https://www.jeasyui.com/easyui/datagrid-export.js instead, and now i have a datagrid-export.js with the toArray function, and everything works.

Jesper


Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: chorauoc on May 13, 2018, 05:12:25 AM
Hey,

Can you please add this extension in the Extension section in the WEB, because this is not available yet, have to come here to this post to get it



Title: Re: Printing - Convert to csv, xls, pdf from datagrid
Post by: jarry on May 13, 2018, 07:41:18 AM
It can be obtained on https://www.jeasyui.com/extension/datagrid_export.php