EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Franky on June 08, 2021, 12:47:11 AM



Title: [SOLVED] Datagrid Export only specify columns from the grid.
Post by: Franky on June 08, 2021, 12:47:11 AM
Hi Sir,

Would like to ask, is there possible to export to excel/csv for specify columns only from a datagrid?

Note: I have implemented datagrid with filter and export extension, all working fine after guided by Jarry.


Title: Re: Datagrid Export only specify columns from the grid.
Post by: Franky on June 12, 2021, 06:22:55 PM
Bump, anyone can please help?


Title: Re: Datagrid Export only specify columns from the grid.
Post by: jarry on June 14, 2021, 03:40:39 PM
Please specify the 'fields' parameter while calling the 'toCsv' or 'toExcel' methods. Be sure to download a newer version from https://www.jeasyui.com/extension/datagrid_export.php
Code:
$('#dg').datagrid('toCsv', {
    filename: 'datagrid.csv',
    fields: ['itemid','productid'],
    rows: rows,
    footer: [{
        productid: 'Summary',
        listprice: 30
    },{
        productid: 'Summary',
        listprice: 40
    }]
});


Title: Re: Datagrid Export only specify columns from the grid.
Post by: Franky on June 15, 2021, 12:20:48 AM
Please specify the 'fields' parameter while calling the 'toCsv' or 'toExcel' methods. Be sure to download a newer version from https://www.jeasyui.com/extension/datagrid_export.php
Code:
$('#dg').datagrid('toCsv', {
    filename: 'datagrid.csv',
    fields: ['itemid','productid'],
    rows: rows,
    footer: [{
        productid: 'Summary',
        listprice: 30
    },{
        productid: 'Summary',
        listprice: 40
    }]
});

Hi Jarry,

Thanks again for your help. This new enhancement work pretty good and as expected.
Thanks ya bro!