material-table icon indicating copy to clipboard operation
material-table copied to clipboard

how to get the index of rowdata

Open tkk777 opened this issue 5 years ago • 2 comments

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> 
      },

  ];

tkk777 avatar Aug 18 '21 03:08 tkk777

`handleClickedRow = (event, rowData) => { console.log(rowData.id) };

;`

maitedev avatar Sep 16 '21 18:09 maitedev

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.

stale[bot] avatar Dec 15 '21 20:12 stale[bot]