import { useEffect, useState } from "react"; import axios from "axios"; import { AgGridReact } from 'ag-grid-react'; import React from 'react'; import 'ag-grid-community/dist/styles/ag-grid.css'; import 'ag-grid-community/dist/styles/ag-theme-alpine.css'; function Read(props) { const [record, setRecord] = useState(''); useEffect(() => { axios.get('https://jsonplaceholder.typicode.com/comments') .then((response) =>{ console.log(response.data); setRecord(response.data); }) }, []) function update(data){ console.log("hello"); } const col= [ { headerName: "Name", field: "name"}, { headerName: "Email", field: "email"}, { headerName: "Body", field: "body"}, {headerName: "", headerClass: 'new-class', cellRendererFramework:(params)=> <div> <button onClick={() => update(params.data)}>Edit</button> </div>} ] return ( <> <div className="ag-theme-alpine" style={{height:'400px', width: '700px'}}> <AgGridReact columnDefs={col} rowData={record} > </AgGridReact> </div> </> ); } export default Read;
i tried to find a way to update the row on click button but i didn't find any thing which will be helpful. I am trying to learn how to do basic crud with ag grid from front end i found a way delete the row which is easy but for update i didn't find anything which will help. so please if any body know how to do that please let me know
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)