gregnb / mui-datatables

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

Custom Date Filter | Issue on removing filter #1726

Open ahmadalauddin opened 3 years ago

ahmadalauddin commented 3 years ago

I have been trying to implement a custom date filter. I have been able to get some help from the age filter from within the examples and trying to implement 'to' and 'from' date in it and it works fine. However when I cancel or clear the filter, it makes another random pill and when I overcame the problem by several hours of debugging and adding the custom code, I was able to get rid of the pill but I am still stuck with another issue, which I have shown in the screenshot attached

Capture Capture Capture1 Capture3

Expected Behavior

When I clear the custom date filter everything should work as expected and I should be able to apply the filters again

Current Behavior

When I clear the filter, it works, but when I reapply the filter it gives the error in the screenshot

Steps to Reproduce (for bugs)

  1. Apply custom date filter 'to' and 'from'
  2. Remove the filter
  3. Reapply the filter

Your Environment

ReactJS "@material-ui/core": "^4.11.0", "mui-datatables": "^3.4.1",

alexdemartos commented 3 years ago

Hi,

I managed to solve this issue by using the customFilterListOptions property to properly initialize the corresponding filterList to an array of two values after a chip clearing:

customFilterListOptions: {
  update: (filterList, filterPos, index) => {
    filterList[index] = [null, null];
    return filterList;
  }
},