angularjs - exportDataAsCsv is not supported property or method of gridOptions.api -


according ag-grid docs here there method on gridoptions.api allows data export of table contents. however, whenever run function, error object doesn't support property or method 'exportdataascsv'.

it's running in directive looks little this:

app.directive('mydirective', function() { restrict: 'e', template-url: "blah.html", link:{pre: function(scope,ele){     var columndefs = [         { headername: "management name", field: "managementname", width: 300 },         { headername: "location", field: "location", width: 150 },         { headername: "backend system", field: "vendor", width: 110 },         { headername: "total active sites", field: "totalactivesites", width: 110 }     ];     scope.gridoptions = { columndefs: columndefs, rowdata: null } },   post: function (scope,ele) {     scope.exportcsv = function() { scope.gridoptions.api.exportdataascsv(); }     scope.gridoptions.rowdata = datalist;     scope.gridoptions.api.onnewrows(); } 

and html looks this:

<input placeholder="filter..." type="text" ng-model="gridoptions.quickfiltertext" /> <button ng-click="exportcsv()">     <img id="btnexporttoexcel" alt="csv file" src="../images/excel.gif" style="cursor:pointer;" tooltip-placement="bottom" uib-tooltip="excel" /> </button> <div ag-grid="gridoptions" class="ag-blue" style="height:100%"></div> 

the grid runs fine, reason doesn't believe method exists. ideas on why might be? i'm using version 1.12 of ag-grid. i'm assuming references good, or else wouldn't grid show @ all.

exportdataascsv() wasn't introduced until version 2.0. you'll need upgrade newer version of ag-grid @ v5.x.

if you're absolutely stuck v1.12, shouldn't hard write own csv data exporter.

here's proof of concept on jsfiddle converts json data csv format , exports user can save it. use this, you'll need give data ag-grid (or own data model supplied ag-grid in first place).

export ag-grid data csv


Comments