Skip to content
This repository has been archived by the owner on Jul 25, 2021. It is now read-only.

Dynamically created table not working #22

Closed
D09r opened this issue Sep 25, 2016 · 4 comments
Closed

Dynamically created table not working #22

D09r opened this issue Sep 25, 2016 · 4 comments
Labels

Comments

@D09r
Copy link

D09r commented Sep 25, 2016

Hi,

I have a table with fixed thead on html and row appended dynamically by JS. Exporting files return only thead and dynamically appended rows are not exported.

var liveTableData = $("#liveTable").tableExport({
    headings: true,                    // (Boolean), display table headings (th/td elements) in the <thead>
    footers: true,                     // (Boolean), display table footers (th/td elements) in the <tfoot>
    formats: ["xlsx", "xls", "csv", "txt"],    // (String[]), filetypes for the export
    fileName: "id",                    // (id, String), filename for the downloaded file
    bootstrap: true,                   // (Boolean), style buttons using bootstrap
    position: "bottom",                 // (top, bottom), position of the caption element relative to table
    ignoreRows: null,                  // (Number, Number[]), row indices to exclude from the exported file
    ignoreCols: null                   // (Number, Number[]), column indices to exclude from the exported file
    ignoreCSS: ".tableexport-ignore"   // (selector, selector[]), selector(s) to exclude from the exported file
});

/* update */
liveTableData.update();

/* reset */
liveTableData.reset();

/* remove */
liveTableData.remove();
@clarketm
Copy link
Owner

clarketm commented Oct 1, 2016

I will take a look at the reset() command and see if there is any flawed logic. You are running liveTableData.reset(); after dynamically appending the table rows, correct?

@clarketm clarketm added the fixed label Nov 21, 2016
@clarketm
Copy link
Owner

I am closing this issue as fixed (90+ days without a reply). If this is not the case please reopen.

@razuro
Copy link

razuro commented Feb 27, 2017

Hi @clarketm, thanks for this awesome plugin!

However, I'm facing the same problem as @D09r. It seems that the plugin doesn't like dynamically created table. I even initialize it after the dynamic table created.

Here's my code:
$("#getReportbtn").on("click", function(){ $.getJSON("http://localhost/job/job_report", function (json) { var tr; for (var i = 0; i < json.length; i++) { tr = $("</tr>"); tr.append("<td>" + json[i].job_id + "</td>"); $("#reportJobs").append(tr); } });
var e2e = $("#reportJobs").tableExport( { headings: true, formats: ["xlsx"], fileName: "id", bootstrap: true, position: "bottom", ignoreRows: null, ignoreCols: null, ignoreCSS: ".tableexport-ignore" } ); });

TIA

@razuro
Copy link

razuro commented Feb 27, 2017

OK my bad. I should wait until json has completely loaded. Added .then after the json called fixed it. Case closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants