Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
I am having problem when adding a working update button inside material ui datagrid v5.6.1

I am trying to add a button inside my material ui datagrid row.

My datagrid component

<DataGrid
    rows={adminStorage}
    columns={columns}
    autoPageSize
    getRowId={(logistics) => logistics._id }
    autoHeight
    headerHeight={60}
    pageSize={100}
    className={classes.root}
/>

the column

    {
        ...
        field: "update",
        align:"left",
        headerAlign: "left",
        headerName: "Update",
        renderCell: (cellValues) => {
            return (
                <Button pL={2} onClick={updateHandler} variant="contained" color="primary">
                    update
                </Button>
            )
        }
    },

the update handler

const updateHandler = (cellvalues) => {
     console.log("The data botained fron the handler is", cellvalues)
}

I want it to work in such a way that when the button is clicked it links to another page that has edit form as well as getting that specific row object and its id

What should i do?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

React is still javascript, according to react https://reactjs.org/docs/handling-events.html#passing-arguments-to-event-handlers you can

<button onClick={(e) => this.deleteRow(id, e)}>Delete Row</button>
<button onClick={this.deleteRow.bind(this, id)}>Delete Row</button>

In both cases, the e argument representing the React event will be passed as a second argument after the ID. With an arrow function, we have to pass it explicitly, but with bind, any further arguments are automatically forwarded.

You can also retrieve further data from the clicked element by using the passed event and the target attribute like

const updateHandler = (event) => {
     let element = event.target;

     console.log("The data botained fron the handler is", element.getAttribute("attribute"))
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda