2

I'm using the code provided in the ui-grid documentation to implement export functionality to my data grid, as given here: http://ui-grid.info/docs/#/tutorial/206_exporting_data

This line is throwing two errors:

exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location"))

First error, in grunt build: 'document' is not defined

Second error, in browser console: TypeError: Cannot read property 'querySelectorAll' of undefined

I've made sure to inject 'ui.grid.exporter', 'ui.grid.selection', and 'ui.grid' in the angular module.

Why would "document" fail as undefined?

5
  • I'm having the same problem with the same error (minus the grunt build error), and when I try just not setting exporterCsvLinkElement I get this error: Exporter asked to export as csv, but no element provided. Perhaps you should set gridOptions.exporterCsvLinkElement? Commented Feb 3, 2015 at 17:34
  • There's also an issue opened on github: github.com/angular-ui/ng-grid/issues/2698 Commented Feb 3, 2015 at 17:39
  • Yes, I get that same "Exporter asked to export as csv, but no element provided. Perhaps you should set gridOptions.exporterCsvLinkElement?" error when I don't set the exporterCsvLinkElement option. Commented Feb 3, 2015 at 19:20
  • Question solved, sort of: I'm getting the error because the code sample came from the latest unstable release of ui grid, but I have an older version installed. Commented Feb 4, 2015 at 16:08
  • I'm currently running 3.x RC 18 and still getting the issue.. I don't know how far ahead unstable is. Commented Feb 4, 2015 at 16:12

3 Answers 3

1

The moment I installed csv.js, it worked like a charm.

Sign up to request clarification or add additional context in comments.

Comments

0

I had the same issue and got mine to work. The documentation is not complete. First make sure you add csv.js to your project. You can do it via bower install, then include the js file.

Then in your html add, this will bind with the property and will be found in the document. If the query doesn't find anything it returns undefined

<div class="custom-csv-link-location">
        <label>Download your CSV:</label>
        <span class="ui-grid-exporter-csv-link">&nbsp</span>
</div>

1 Comment

That's actually for the older version - the new, unstable version does an automatic download without the need for creating a hyperlink first. In the end, because our project team didn't want to use an unstable version, I ended up using ngCsv instead and it worked like a charm.
0

I included ui-grid-exporter in my HTML and it's working for me.

Before:

div class="myGridRuleInfo" id="gridTrades1" ui-grid="ri.gridOptions" ui-grid-resize-columns ui-grid-grouping ui-grid-move-columns

After:

div class="myGridRuleInfo" id="gridTrades1" ui-grid="ri.gridOptions" ui-grid-resize-columns ui-grid-grouping ui-grid-move-columns ui-grid-exporter

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.