I would like to add a button for an ag-grid table column in reactjs at the time column definition. And onclick I need to call a class function. I would like to create onclick event and pass the params value to the function and make an api call from there.
columnDefs = [{
..... {
headerName: "View",
field: "id",
sortable: false,
filter: false,
colId: "view",
cellRendererFramework: function(params) {
return <Button onclick = {
this.handleClick
} > Test < /Button>
},
},
......
];
}
handleClick() {
console.log("some API call and state change");
}
render() {
return ( <
div >
<
div id = "myGrid"
style = {
{
height: "100%",
width: "100%"
}
}
className = "ag-theme-material" >
<
AgGridReact enableSorting = {
true
}
groupSelectsChildren = {
true
}
rowData = {
this.state.organization
}
columnDefs = {
this.columnDefs
}
onGridReady = {
this.onGridReady
} >
<
/AgGridReact>
<
/div>
}
export default OrganizationList;
cellRendererFramework: (props) => { return ( <button onClick{this.handleClick.bind(this)>Click</button> } ); }
– Santhosh A