mui-datatables icon indicating copy to clipboard operation
mui-datatables copied to clipboard

Is it possible to make custom component filter?

Open dapapkung opened this issue 7 years ago • 12 comments

Expected Behavior

There is 4 filter type in mui-datatables: dropdown, checkbox, textField, and, multiselect. Is it possible to make custom filter component in mui-datatables?

For ex: I want to replace that 4 filter type with my own component(for ex: other library).

And, can i use different filterType on each column? for ex:

column: [
      {
        name: 'Username',
        options: {
          filter: false,
          sort: false,
          filterType: 'textField',
        },
      },
      {
        name: 'Date',
        options: {
          filter: true,
          sort: false,
          filterType: 'multiselect',
        },
      },
      {
        name: 'Age',
        options: {
          filter: true,
          filterType: 'dropdown',
          sort: false,
        },
      }
]

Thank you

Current Behavior

I already tried this: link but it's not working for me.

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Your Environment

Tech Version
Material-UI 3.8.2
MUI-datatables 2.0.0-beta-53
React 16.6.0
browser Chrome
etc

dapapkung avatar Feb 20 '19 10:02 dapapkung

Bump +1

doc82 avatar May 17 '19 00:05 doc82

+1, would be great to have date picker as a filter.

PresentProgrammer avatar May 23 '19 08:05 PresentProgrammer

Bump +1

Stanley-Okwii avatar Jun 03 '19 20:06 Stanley-Okwii

Custom filters are coming, and there's a PR open for it now: https://github.com/gregnb/mui-datatables/pull/578

gabrielliwerant avatar Jun 03 '19 21:06 gabrielliwerant

Bump +1

BingyuLiu avatar Jun 04 '19 19:06 BingyuLiu

it works for me, but I when do build production. it doesn't work before image

jsnavarroc avatar Jun 06 '19 15:06 jsnavarroc

Yes, you can provide a different filter type for each column via filterType on the column options. As of 2.4.0 you can also set custom filter logic via filterOptions: { logic: function }.

gabrielliwerant avatar Jun 12 '19 02:06 gabrielliwerant

@gabrielliwerant , I recently used customRowRender to build custom rows for the table. Despite including the filter option as a checkbox. I noticed that when I use custom rows, I lose the ability to selection given rows.

Stanley-Okwii avatar Jun 12 '19 07:06 Stanley-Okwii

@Stanley-Okwii Your issue doesn't sound like it pertains to custom filters. Can you please up a new issue with specific steps to reproduce your issue so that we may track it separately?

gabrielliwerant avatar Jun 12 '19 07:06 gabrielliwerant

okay. cool

Stanley-Okwii avatar Jun 12 '19 07:06 Stanley-Okwii

It is now possible, as of 2.6.0, to add custom rendering for filters, thanks to @Avd6977!

Use filterOptions: { display: Component } and filterType: 'custom' in the column options.

gabrielliwerant avatar Jul 02 '19 05:07 gabrielliwerant

can you give a example

rush2212 avatar Jun 27 '23 07:06 rush2212