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

No idea how to make this work #3

Open
ErikThiart opened this issue Apr 13, 2021 · 1 comment
Open

No idea how to make this work #3

ErikThiart opened this issue Apr 13, 2021 · 1 comment

Comments

@ErikThiart
Copy link

Cannot read property 'toCSV' of undefined

<button type="button" class="btn btn-sm btn-primary ml-2" onclick="csvExport()">CSV</button>

              <script>
                  var datatable = new simpleDatatables.DataTable("table", {
                      exportable: {
                          type:'csv',
                          download:true,
                          escapeHTML: true,
                          includeHeadings: true
                      }
                  });
                
                  function csvExport() {
                    datatable.exportable.toCSV();
                  }
              </script>

Please provide some sample code on how to make this work using https://github.com/fiduswriter/Simple-DataTables

@SharkFourSix
Copy link

SharkFourSix commented Oct 3, 2021

It doesn't work. It works on the assumption that there's an object named window.DataTable (Here

if (window.DataTable) {
).

If it can't find it, it will not extend the library. You can change it yourself or just resort to the old function

myInstance.export({ type: 'csv', download: true })

https://github.com/fiduswriter/Simple-DataTables/wiki/export()

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

No branches or pull requests

2 participants