gregnb / mui-datatables

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

Custom parameters/Row data in custom filter logic function #803

Open yokeshwar93 opened 5 years ago

yokeshwar93 commented 5 years ago

I wanted to know if there is an option to either pass custom parameters to the custom filter logic function or get the row data inside the function.

Expected Behavior

Pass custom parameters, to custom filter logic Pass the rowData to the custom filter logic function

Current Behavior

Accepts only the column data and filter value

gabrielliwerant commented 5 years ago

The logic function passes (value, filters) where the value is the value of the cell data being evaluated by the column and the filters are all of your filter options (array). That ought to be enough to create most custom filters. Is there something in particular you're looking to do?

yokeshwar93 commented 5 years ago

Hey, Thanks for the reply. I'm trying to write a custom logic for a specific column based on the value of a different column. Ex : Lets say we have three columns A, B and C and when I want to filter C I want to have two different logic based on the value of A. So If I could get the tableData or the rowData that would be great. Thanks

gabrielliwerant commented 5 years ago

You have access to the table and row data that you pass into the table, so you could try to manage it yourself and then call up those values in the custom filters.

Adding those options to custom filters for such a specific use case is unlikely to happen any time soon, as keeping state managed within the library is complex and a source of bugs at the moment, so I don't want to expand that out just yet.

yokeshwar93 commented 5 years ago

I understand, I do have the table data as a whole but not sure how to get the row specific data during filtering, It would be really helpful if there any way to get that in the logic function. Sorry for the trouble