gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.71k stars 932 forks source link

customBodyRender sometimes receives tableMeta.rowData[0] as undefined and sometimes as data object #1584

Open kickinmhl opened 3 years ago

kickinmhl commented 3 years ago

Question:

I have 2 instances of the table implemented.

I have found that in one table the customBodyRender's second parameter receives tableMeta.rowData index 0 as the entire data object, but in the other implementation tableMeta.rowData index 0 is undefined.

What configuration determines whether the data object is passed as index 0 of tableMeta.rowData?

Column definition:

resourceName: { name: 'resourceName', label: 'Resource Name', options: { filter: true, sort: true, sortDirection: 'none', customBodyRender: (value, tableMeta) => { const rowData = tableMeta.rowData[0]; return ( <Link className={resourceName-link-${rowData.resourceId}} to={getResourceLinkCallback(rowData.resourceId)}

{value} ); } } }

Your Environment

Tech Version
Material-UI 4.5.1
MUI-datatables 2.14.0
React 16.11.0
wdh2100 commented 3 years ago

@karthick-vinod

hmm... it's Interesting If you create a codesandbox showing the problem I can take a look.

kickinmhl commented 3 years ago

I don't know how to reproduce the problem... current code (too much to post in sandbox) shows nearly identical code. That was the question... what determines whether the data object is returned in index 0 or not.