Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

86
Views
how to update the row on button click in ag grid in react

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

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;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

assign an id to it and then pass then id with the update function.Then you can use querySelectors to get that field and update it

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!