Reputation: 525
I am looping through each node of ag-grid data and have to display column values.Attached is the plunkr: https://plnkr.co/edit/cFBLm7DkAZL5oWbqdyub?p=preview.
I am not able to display the ag-grid data in the console.
var gridOptions = {
defaultColDef: {
sortable: true
},
columnDefs: columnDefs,
animateRows: true,
enableRangeSelection: true,
rowData: rowData,
checkbox : true,
onSelectionChanged : getData
};
new agGrid.Grid(gridDiv, gridOptions);
});
function getData(){
gridOptions.api.forEachNode( function (node) {
console.log("node vaalues are:"+node.data);
});
Upvotes: 0
Views: 4107
Reputation: 1743
There are a couple things wrong with your code.
Inorder for onSelectChanged
to be called you need to specify how you want row selection to work, try: rowSelection: 'single'
In your plunkr (not your snippet above), your getData
function is in the wrong scope. By this I mean all of your code is inside the document.addEventListener
, but the getData
is not. Because of this, getData
doesn't know what gridOptions
is.
Updated plunkr: https://next.plnkr.co/edit/cXKVZrT9siHoodVa
Upvotes: 1