question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Overriding filters

See original GitHub issue

I’m confused on how to implement custom filter components. I understand that I need to do something like this:

components={{
          FilterRow: props => (
            //insert custom filters for each column
          )
        }}

but I’m not sure where to go from here to get a differing custom filters for table columns.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

25reactions
ninjasawancommented, Jul 25, 2020
const CustomDatePicker = (props) => {
  const [date, setDate] = useState(null);

  return (
    <DatePicker
      label="Select Date"
      inputVariant="outlined"
      variant="inline"
      format="dd/MM/yyyy"
      value={date}
      ampm
      autoOk
      allowKeyboardControl
      style={{ minWidth: 175 }}
      onChange={(event) => {
        setDate(event);
        props.onFilterChanged(props.columnDef.tableData.id, event);
      }}
      InputProps={{
        endAdornment: (
          <InputAdornment position="end">
            <IconButton>
              <EventIcon />
            </IconButton>
          </InputAdornment>
        ),
      }}
    />
  );
};

Now in column

{
    title: "Created Date",
    field: "order_created_date",
    searchable: false,
    grouping: false,
    sorting: true,
    type: "datetime",
    filterComponent: (props) => <CustomDatePicker {...props} />,
  }
8reactions
phillipbritaincommented, Jun 4, 2019

Solution for anyone with the same question: It dawned on me that I should put on my big boy pants and take a look at the source code. From there, the easiest route to go IMO is to take a copy of the m-table-filter-row.js file, paste it into a new file in your code base, make any modifications you need (in my case, swapping out the MUI select component for a react-select component, and reference it in your table like so (last prop):

    <MaterialTable
        columns={[
          {
            title: "Adı",
            field: "name"
          },
          { title: "Soyadı", field: "surname" },
          { title: "Doğum Yılı", field: "birthYear", type: "numeric" },
          {
            title: "Doğum Yeri",
            field: "birthCity",
            lookup: { 34: "İstanbul", 63: "Şanlıurfa" }
          }
        ]}
        data={[
          { name: "Mehmet", surname: "Baran", birthYear: 1987, birthCity: 63 }
        ]}
        options={{
          filtering: true
        }}
        title="Demo Title"
        icons={tableIcons}
        components={{
          FilterRow: props => <FilterRow {...props} /> <---- your modified filter row component
        }}
      />
Read more comments on GitHub >

github_iconTop Results From Across the Web

What are Filter Overrides?
Filter Overrides are changes made to a filter default settings. In other words, anytime a filter is changed from its "default settings", you...
Read more >
Overriding filter processing phasing - BMC Documentation
To override the phases for a specific filter, for example, one of a sequence of filters executed in a filter guide, you can...
Read more >
How to Stop Overriding Filters in Gmail
Step 4: Scroll to the bottom of the menu, select the Don't override filters option, then click the Save changes button. how to...
Read more >
Filter Overrides in ASP.Net MVC 5
Using the Filter Overrides feature, we can exclude a specific action method or controller from the global filter or controller level filter. In ......
Read more >
Overriding Filters Passed from Another Dashboard
I think the best way to do this is to remove the actual filter from your second dashboard and just leave the action....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found