Getting data from custom widget

I’m using the ag-grid widget in my application. I’m able to send json data and display it in the grid. Now, I have made the grid editable and I want to retrieve the updated values. However, I’m not able to access the ag-grid functions from within the update or setupEvents function. In the _getAllGridRows function, I have the this.gridApi.forEachNode statement which fails with an error Cannot read property 'forEachNode' of undefined TypeError: Cannot read property 'forEachNode' of undefined. It looks like the functions of ag-grid js are not accessible.  Any help is greatly appreciated.  define([ "dojo/_base/declare", "mxui/widget/_WidgetBase", "dijit/_TemplatedMixin", "agGridWidget/widget/lib/ag-grid-community.min.noStyle", "mxui/dom", "dojo/dom", "dojo/dom-prop", "dojo/dom-geometry", "dojo/dom-class", "dojo/dom-style", "dojo/dom-construct", "dojo/_base/array", "dojo/_base/lang", "dojo/text", "dojo/html", "dojo/_base/event", "agGridWidget/widget/lib/jquery-1.11.2", "dojo/text!agGridWidget/widget/template/agGridWidget.html" ], function( declare, _WidgetBase, _TemplatedMixin, agGrid, dom, dojoDom, dojoProp, dojoGeometry, dojoClass, dojoStyle, dojoConstruct, dojoArray, lang, dojoText, dojoHtml, dojoEvent, _jQuery, widgetTemplate ) { "use strict"; var $ = _jQuery.noConflict(true); // Declare widget's prototype. return declare( "agGridWidget.widget.agGridWidget", [_WidgetBase, _TemplatedMixin], { // _TemplatedMixin will create our dom node using this HTML template. templateString: widgetTemplate, // DOM elements //inputNodes: null, //colorSelectNode: null, //colorInputNode: null, //infoTextNode: null, // Parameters configured in the Modeler. mfToExecute: "", gridDataJSON: "", backgroundColor: "", //// More lines of code.. _getAllGridRows: function(){ var rowData = []; this.gridApi.forEachNode(node => rowData.push(; return rowData; }, // Attach events to HTML dom elements _setupEvents: function() { logger.debug( + "._setupEvents"); this.connect(this.saveButton, "click", function (e) { // Only on mobile stop event bubbling! this._stopBubblingEventOnMobile(e); console.log("Clicked and executing mf - 1"); // If a microflow has been set execute the microflow on a click. if (this.mfToExecute !== "") { console.log("Clicked and executing mf"); this.updatedJSON = JSON.stringify(this._getAllGridRows()); this._contextObj.set("JSONString", this.updatedJSON); this._execMf(this.mfToExecute, this._contextObj.getGuid()); } }); }, Thanks, Leo.    
0 answers