Export data table to PDF

Asked

Viewed 398 times

3

I’m using the plugin JS Webix to create grid dynamic. It has a functionality to export to PDF/Excel, on the site has the following example:

grid = new webix.ui({
    view:"datatable",
    columns:[...],
    "export":true
});

and to trigger, the button:

<input type="button" value="Get as PDF" style='width:400px;margin:25px;' onclick="grid.exportToPDF();">

Where grid is the instance of webix.ui that contain the datatable


How do I export if a datatable is inside a layout? Example:

new webix.ui({
    type:"line", id:"a1", rows:[
        {type:"head", padding:0, responsive:"a1", cols:[
                {template:"<?=$rel->getHeader_logo()?>", css:"cabecalho-webix", height:84, minWidth:200},
                {template:"<?=$rel->getHeader_titulo()?>", css:"cabecalho-webix", height:84, minWidth:300},
                {template:"<?=$rel->getHeader_dataemissao()?>", css:"cabecalho-webix", height:84, minWidth:200}
        ]},
        {type:"line", padding:0, responsive:"a1", cols:[
            {
                container:"testA",
                view:"datatable",
                columns: <?= $json; ?>,
                footer:false,
                autoheight:false,
                data:<?= $json_body; ?>,
                scrollAlignY:true,
                export:true,
                resizeColumn:true,
                resizeRow:false,
                dragColumn:true
            }
        ]},
        {type:"line", padding:0, responsive:"a1", cols:[
            {template:"<span id='imprimir' onclick='printGrid();'><img src='images/bt_imprimir.png'></span>", height:60}
        ]}
    ]
}).show();

1 answer

1


First enter an ID:

{
    container:"testA",
    view:"datatable",
    columns: <?= $json; ?>,

    id: "iddatatable"

    footer:false,
    autoheight:false,
    data:<?= $json_body; ?>,
    scrollAlignY:true,
    export:true,
    resizeColumn:true,
    resizeRow:false,
    dragColumn:true
}

Make the call by ID:

$$('iddatatable').exportToPDF();
  • Thanks, that took care.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.