EasyUI Forum
March 28, 2024, 01:36:43 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: [SOLVED AS AN EXTENSION] Printing - Convert to csv, xls, pdf from datagrid  (Read 25465 times)
jega
Full Member
***
Posts: 190


View Profile
« 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
« Last Edit: May 13, 2018, 12:46:16 PM by jega » Logged
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« Reply #1 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.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #2 on: May 06, 2018, 01:32:39 AM »

The exporting extension can be downloaded from https://www.jeasyui.com/extension/downloads/datagrid-export.zip
Logged
jega
Full Member
***
Posts: 190


View Profile
« Reply #3 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

Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #4 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.
Logged
jega
Full Member
***
Posts: 190


View Profile
« Reply #5 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 ;-)
Logged
thecyberzone
Full Member
***
Posts: 176



View Profile Email
« Reply #6 on: May 07, 2018, 01:58:00 AM »

And what about Convert2PDF Huh
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #7 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();
Logged
jega
Full Member
***
Posts: 190


View Profile
« Reply #8 on: May 08, 2018, 11:51:38 PM »

Hi Jarry

Have no method toArray Huh
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #9 on: May 09, 2018, 06:14:23 PM »

Please download a newer version from from https://www.jeasyui.com/extension/downloads/datagrid-export.zip
Logged
proceno72
Newbie
*
Posts: 39



View Profile
« Reply #10 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
Logged
Pierre
Sr. Member
****
Posts: 439


View Profile Email
« Reply #11 on: May 09, 2018, 11:42:16 PM »

Jarry, this is awesome, thank you for your work.  Smiley
Logged
jega
Full Member
***
Posts: 190


View Profile
« Reply #12 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
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #13 on: May 10, 2018, 02:52:01 AM »

Please look at this example http://code.reloado.com/ulosin4/2/edit#preview
Logged
jega
Full Member
***
Posts: 190


View Profile
« Reply #14 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
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!