Page 1 of 1

[Solved] Export Table

Posted: Thu Oct 11, 2018 2:18 pm
by brunogz
I'm trying to export the data from a table, but I'm getting the following error:
Unable to get property 'export' of undefined or null reference

Code: Select all

   
function exportaTabela() {
        var table = $("#tblBusca").data('table');

        table.export('CSV', 'all', 'table-export.csv', {
            csvDelimiter: "\t",
            csvNewLine: "\r\n",
            includeHeader: true
}); 
#tblBusca is the id of the table I want to export.

Thanks.

Re: Export Table

Posted: Thu Oct 11, 2018 2:32 pm
by olton
Check metro4 version for latest

Re: Export Table

Posted: Thu Oct 11, 2018 3:00 pm
by brunogz
I'm using Metro 4. I found this example here: https://metroui.org.ua/table-component. ... ble_export

Re: Export Table

Posted: Thu Oct 11, 2018 4:52 pm
by olton
Check your metro4 version. Must be 4.2.24

Re: Export Table

Posted: Thu Oct 11, 2018 11:47 pm
by brunogz
Thank you very much for your attention.
Is my code correct? The version is right.

/*
* Metro 4 Components Library v4.2.24 build 702 (https://metroui.org.ua)
* Copyright 2018 Sergey Pimenov
* Licensed under MIT
*/

Re: Export Table

Posted: Fri Oct 12, 2018 12:09 am
by olton
Show your code where table is defined. Check, if table have role "table" with attribute "data-role".

To export any table without role "table", you must use object Metro.export.

Code: Select all

<table id="myTable">...<table>
...
var export = Metro.export.tableToCSV;
export($('#myTable'), "export.csv", {
        csvDelimiter: "\t",
        csvNewLine: "\r\n",
        includeHeader: true
    })