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

282
Views
En tabla materia-ui. Cuando hago clic en el botón para expandir la fila, se expanden todas las filas. ¿Cómo puedo hacer que solo la fila seleccionada se expanda?

El evento Row Click expande todas las filas en la tabla de datos para mostrar los datos internos de todas las filas

Al hacer clic en el botón Expandir, se expanden todas las filas en lugar de la fila seleccionada. Cada vez que haga clic en el botón para expandir la fila 1, también expandirá la segunda fila. ¿Cómo puedo arreglar esto donde solo se expandirá esa fila específica?

 <Table stickyHeader aria-label="sticky table"> <TableHead> <TableRow hover> <TableCell>Title</TableCell> <TableCell>Created Date</TableCell> </TableRow> </TableHead> <TableBody> {data && data((index) => ( <TableRow hover> <TableCell> <IconButton aria-label="expand row" size="small" onClick={() => setOpen(!open)} > {open ? ( <KeyboardArrowUpIcon /> ) : ( <KeyboardArrowDownIcon /> )} </IconButton> </TableCell> <TableCell component="th" scope="row"> {index.title} </TableCell> <TableCell component="th" scope="row"> {new Date( index.createdDate.seconds * 1000 ).toDateString()} </TableCell> <TableCell colSpan={6}> <Collapse in={open} timeout="auto" unmountOnExit> {index.text} </Collapse> </TableCell> </TableRow> ))} </TableBody> </Table>

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Pude agregar el índice para abrir la función y permitir solo la expansión de fila seleccionada. Funciona como se esperaba y debajo está mi código modificado.

 <Table stickyHeader aria-label="sticky table"> <TableHead> <TableRow hover> <TableCell>Title</TableCell> <TableCell>Created Date</TableCell> </TableRow> </TableHead> <TableBody> {data && data((index) => ( <TableRow hover> <TableCell> <IconButton aria-label="expand row" size="small" onClick={() => setOpen(open === index ? -1 : index)} > {open == index ? ( <KeyboardArrowUpIcon /> ) : ( <KeyboardArrowDownIcon /> )} </IconButton> </TableCell> <TableCell component="th" scope="row"> {index.title} </TableCell> <TableCell component="th" scope="row"> {new Date( index.createdDate.seconds * 1000 ).toDateString()} </TableCell> <TableCell colSpan={6}> <Collapse in={open == index} timeout="auto" unmountOnExit> {index.text} </Collapse> </TableCell> </TableRow> ))} </TableBody> </Table>

about 4 years ago · Santiago Gelvez 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!