I can't figure out how to redirect page to certain URL based on which row in ag-grid table user have clicked. All I need is value from one of the cells within a row. I came up with two approaches:
First is to make all rows a class, and then add a click listener to it but to me it feels kinda ugly and not performant when there will be huge amount of rows.
Second approach is about making an event, but in this case I don't know how to pass any kind of information from which row it was called. It can be even value of one of the cells.
var gridOptions = {
onRowClicked: event => console.log("Row clicked")
};
And i want something like:
var gridOptions = {
onRowClicked: event => myFunction(someCell.data)
};
If first solution is not a bad practice, please let me know!
Pass the event parameter to your function which should contain the data from the row that was clicked.
const gridOptions ={
rowData: [
{make: "Toyota", model: "Celica", price: 35000},
{make: "Ford", model: "Mondeo", price: 32000},
{make: "Porsche", model: "Boxter", price: 72000}
],
onRowClicked: event => myFunction(event)
}
const myFunction = (event) => {
console.log('rowData:')
console.log(event.data)
}