Is it possible not to make all columns filterable in React table

Viewed 2884

I am working on implementation filter method in react table. If I add filterable attribute it gives me filter input in all columns but I want not to add filter input in specific column.

Is there any solution about this?

3 Answers

If you want a specific column to not be filterable, you can specifiy it when creating your columns like this :

const columns = [
  {
    Header: 'NotFilterableColumn',
    accessor: 'notFilterable',
    filterable: false  //This makes the column not filterable
  },
  {
    Header: 'FilterableColumn',
    accessor: 'filterable',
  }
]

So that giving the filterable attribute to your ReactTable will not make the NotFilterableColumn filterable :) (in other words, the column will not have the filter input)

To disable filter from specific columns in react table add the disableFilters options to the column. it takes in a boolean value . Here is a code snippet below

   const columns = [
  {
    Header: "Name",
    accessor: "Project Name",
    disableFilters:true
    }]

read more in document

Implement your own filter logic. React-table provide callbacks for everything you need to implement it on your own:

onPageChange: undefined,
onSortedChange: undefined,
onFilteredChange: undefined,

Check props part of documentation and there are exhaustive documentation on it.

Related