gregnb / gregnb/mui-datatables
customSearch and customBodyRender
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 906
- PR merge metrics
- No merged PRs in 30d
Description
When I use customBodyRender in column definition for access to nested data and format it.
For the correct search, I must use customSearch function.
But customSearch function as parameters got only: searchQuery as a string, currentRow as array of values, columns definition array.
It's work for regular columns, but the column with customBodyRender got "undefined" values in currentRow array.
for Ex:
```
const columns = [
{
name: "id",
},
{
name: "filename",
},
{
name: "internalID",
options: {
customBodyRenderLite: (dataIndex:number) => {
const item = this.state.data[dataIndex] as any;
if(item && item.metadata) {
return item.metadata.internalID;
}
}
}
}];
```
```
const options = {
customSearch: (searchQuery:string, currentRow:any[], columns:any[]) => {
console.log('customSearch', searchQuery, currentRow, columns);
return true;
},
};
```
CONSOLE LOG:
customSearch t (3) ["1", "filename", **undefined**] (3) [{…}, {…}, {…}]
Will be very helpful if function customSearch will get additional parameter **dataIndex** that we can see in other functions
This index will simplify to access current raw data and get internal values, that not listed in the table
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.