[英]Open a dialog on row selection [material-table]
沒有本地解決方案可以像您想要的那樣使用材料表顯示彈出窗口。 但是你可以做到這一點。
您在 MaterialTable 中有一個名為 onRowClick 的道具。
<MaterialTable onRowClick={(evt, selectedRow) => yourFunction(selectedRow)} />
使用這個道具,你可以定義你自己的函數來打開一個彈出窗口( https://material-ui.com/components/popper/ )或任何你想要的彈出類型組件,點擊行並在其中顯示所選表格行的信息.
這樣,您甚至可以使用顯示更多詳細信息的 id 請求獲取更多詳細信息!
例子:
const alertMyRow = (selectedRow) => (
// here i can request something on my api with selectedRow.id to get additional
// datas which weren't displayed in the table
alert(`name: ${selectedRow.name}, surname: ${selectedRow.surname}`);
);
return(){
render(
<MaterialTable
columns={[
{ title: 'ID', field:'id' },
{ title: 'Name', field: 'name' },
{ title: 'Surname', field: 'surname' },
{ title: 'Phone Number', field: 'phone' },
]}
datas={[...]}
onRowClick={(evt, selectedRow) => alertMyRow(selectedRow)}
/>
)
);
如果我不夠清楚,請不要猶豫;)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.