material-table
material-table copied to clipboard
how to get the index of rowdata
How can I get the row index?
It is because I need to get the row index to open the detail panel by function onToggleDetailPanel
https://github.com/mbrn/material-table/issues/1340
So I tried to define the column and add icon to trigger function "onToggleDetailPanel" in cells
I tried to use rowData.tableData.id but it cannot handle after sorting or filtering
const tableColumns = [
{
title: <span>TEST</span>,
field: "TEST",
width:"187px",
cellStyle:{
width:"187px"
},
headerStyle: TableHeaderStyle2,
sorting: false,
render: (rowData) =>
<div>
<IconTick style={{
width: '18px',
height: '18px',
fill:'#345349',
cursor: "pointer",
}}/>
<InfoIcon
style={{
width: '18px',
height: '18px',
fill:'#345349',
cursor: "pointer",
}}
onClick={() =>
tableRef.current.onToggleDetailPanel([(rowData.tableData.id)], rowData2 =>
<CustomDetailPanel
data1={rowData.data1}
totalData={totalData}
tableDataId={rowData.tableData.id}
data2={rowData.data2}
returnType={"Test"}
data3={rowData.data3}
data4={rowData.data4}
/>
)
}
/>
</div>
},
];
`handleClickedRow = (event, rowData) => { console.log(rowData.id) };
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.