Vortilion
Vortilion

Reputation: 424

Programmatically trigger onRowClicked-event

Is there a way to manually trigger the Grid-Event onRowClicked programmatically? If I set a node to selected via

node.setSelected(true);

, the event isn't being triggered... Only if I really click on it, but I need to trigger it programmatically too, as a reaction to a service-call.

Upvotes: 0

Views: 1325

Answers (1)

ViqMontana
ViqMontana

Reputation: 5698

Seems pretty simple to me. Just call the onRowClicked function on your gridOptions. Seeing as you already have your node, you should be able to get the row and pass it to your onRowClicked function.

var gridOptions = { 
  columnDefs: columnDefs,
  rowData: rowData,
  onRowClicked: function(params)
  {
    console.log('Row Make: ' + params.data.make);
  }
};

function clickRowOne()
{
  const node = gridOptions.api.getRowNode(0);
  gridOptions.onRowClicked(node);
}

Demo.

Upvotes: 2

Related Questions