简体   繁体   中英

Open Dialog onRowClick [Material-Table] [React]

I am using React Material-Table ( https://material-table.com/#/ ). How can I display a dialog when I click on a table row? I tried to achieve this with onRowClick property, but I could not find appropriate examples with this property and how can I call my Dialog component with it. Could someone help with this? Thanks in advance!

Maybe you can try this, I use hooks and Dialog component from material ui for this example. onRowClick function will change showDialog state to true and Dialog will show if showDialog is true

const [showDialog, setShowDialog] = useState(false);

return(
<MaterialTable
   onRowClick={(evt,rowData)=>{setShowDialog(true)}}
/>
<Dialog open={showDialog}/>
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM