0

I have written a code to export records from a particular page by using javascript.

<button class="slds-button slds-button--neutral slds-button--small" onclick="exportTrademarkTable('Export.csv')">Export</button>
<script>
function downloadCSV(csv, filename) {
    var csvFile;
    var downloadLink;

    // CSV file
    csvFile = new Blob([csv], {type: "text/csv"});

    // Download link
    downloadLink = document.createElement("a");

    // File name
    downloadLink.download = filename;

    // Create a link to the file
    downloadLink.href = window.URL.createObjectURL(csvFile);

    // Hide download link
    downloadLink.style.display = "none";

    // Add the link to DOM
    document.body.appendChild(downloadLink);

    // Click download link
    downloadLink.click();
    }
function exportTrademarkTable(filename) {
    var csv = [];
    var rows = document.querySelectorAll("#trademark-table tr");

    for (var i = 0; i < rows.length; i++) {
        var row = [], cols = rows[i].querySelectorAll("td, th");

        for (var j = 1; j < cols.length; j++) 
            row.push(cols[j].innerText);

        csv.push(row.join(","));        
    }

    // Download CSV file
    downloadCSV(csv.join("\n"), filename);

}
</script>

As of now I am getting only single(Table) page data. I am trying to export all records which are present in the object

  • 3
    Saying please can anyone help me is not a real question. Please be ask how to achieve something specific. – Adrian Larson May 25 '17 at 12:03
-1

That is not possible,because the data are coming from server side.you can do it by using jquery

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy