grid for CRUD application.
I've some data that shown in ag-grid table like this
I've used ag-grid cell renderer to render that button
import React, { Component } from 'react';
export default class DeleteButton extends Component {
render() {
return (
<span><button onClick={}>X</button></span>
);
}
}
I store the data and column defs in component's state like this
this.state = {
rewData : [
{make: "Toyota", model: "Celica", qty:12, price: 35000, test:"", image:""},
{make: "Ford", model: "Mondeo", qty:1, price: 32000, test:"", image:""},
{make: "Porsche", model: "Boxter", qty:8, price: 72000, test:"", image:""},
{make: "Porsche", model: "Boxter", qty:8, price: 72000, test:"", image:""}
],
columnDefs:[
{"headerName":"Make","field":"make","cellEditor":"textCellEditor","cellEditorParams":{"required":true}},
{"headerName":"Model","field":"model","cellEditor":"multiLineTextCellEditor","cellEditorParams":{"required":true}},
{"headerName":"Qty","field":"qty","cellEditor":"numericCellEditor","cellEditorParams":{"required":true}},
{"headerName":"Price","field":"price","cellEditor":"numericCellEditor","cellRenderer":"currencyCellRenderer","cellEditorParams":{"required":true}},
{"headerName":"test","field":"test","cellEditor":"manyToOneCellEditor","cellEditorParams":{"model":"account","host":"http://localhost:8282","fieldAsLabel":"name","fieldAsValue":"id","required":true}},
{"headerName":"image","field":"image","cellEditor":"fileUploadCellEditor","cellRenderer":"imageCellRenderer","cellEditorParams":{"required":true}},
{"headerName":"Delete","cellRenderer":"deleteButton"}
]
}
and passed that in ag-grid's rowData props:
<AgGridReact
defaultColDef={defaultColDef}
columnDefs={this.state.columnDefs}
rowData={this.state.rowData}
onGridReady={this.onGridReady}
onCellValueChanged={this.handleChange}
frameworkComponents={this.state.frameworkComponents}
singleClickEdit={true}
stopEditingWhenGridLosesFocus={true}
reactNext={true}
/>
when I clicked the delete button, I want to delete corresponding row and also other things like validation or show notification to user, etc
how do i make that button works changing state of rowData?
where do i put the method to change rowData's state?