table icon indicating copy to clipboard operation
table copied to clipboard

Not able to disable filter for one column.

Open hbulgarini opened this issue 9 years ago • 24 comments

Hello !

I'm trying to disable the filter by adding the property "filterable:false" on one specific column , but i'm afraid that this is not working and the filter is shown anyway for that column. Here is my setup for the specific column:

        const columns = [
            {
                header: '',
                accessor:'contract_id',
                filterable:false,
                render: ({value}) => (<button className="btn " onClick={(e) => this.ShowContract(e, value)}>Ver</button>)
}

Any ideas why it is not working? Do i'm settting in the incorrect way or the option for disable filters is not working?

Thanks!

hbulgarini avatar Jun 10 '17 00:06 hbulgarini

Hi,

I was able to disable filtering by adding it like this:

    const columns = [
      {
        Header: 'Name',
        accessor: 'name',
      },
      {
        Header: 'E-mail',
        accessor: 'email',
        sortable: false,
        filterable: false,
      },
      {
        Header: 'Country',
        accessor: 'country',
      }
    ];

antoniwan avatar Jun 19 '17 21:06 antoniwan

This should work just fine. https://codepen.io/tannerlinsley/pen/XgZgeg?editors=0010

tannerlinsley avatar Jun 29 '17 22:06 tannerlinsley

Hello Guys, thanks for your reply but i'm still not able to disable the filter after adding the filterable:false property on the column definition: Please check my code:

        const columns = [
            {
                header: 'Nombre',
                accessor:'name',
                filterable:false
            },
            {
                header: 'Tipo',
                accessor: 'type',
            },
            {
                header: 'Teléfono',
                accessor: 'tel',
            },
            {
               header: 'Email',
                accessor: 'email',
            }
        ]

And here is how i define my react-table

    <ReactTable className="-striped -highlight"
                            columns={columns}
                            defaultPageSize={10}
                            data={data} // should default to []

                            loading={this.state.loading}
                            showFilters={true}
                            previousText={'Anterior'}
                            nextText={'Siguiente'}
                            loadingText={'Cargando...'}
                            noDataText={'No existen registros'}
                            pageText={'Siguiente'}
                            ofText={'de'}
                            rowsText={'lineas'}
                            getTdProps={(state, rowInfo, column, instance) => {

                                var ret = {

                                    onClick: e => {
                                        if (this.state.CurrentID ==rowInfo.row.person_id ){
                                            this.setState({CurrentID: null,CurrentName: null});
                                            this.setState({message_class: "animated fadeOut",alertmessage:""})
                                            this.setState({Visible: "hidden"})
                                        }
                                        else{
                                            this.setState({CurrentID: rowInfo.row.person_id,CurrentName: rowInfo.row.name});
                                            this.setState({message_class: "animated fadeOut",alertmessage:""})
                                            this.setState({Visible: "visible"})
                                        }


                                    }
                                }
                                if(rowInfo && (this.state.CurrentID == rowInfo.row.person_id)){
                                    ret.style = { background: '#B0C4DE'}

                                }
                                return ret;
                            }}
                    />

Any comments?

hbulgarini avatar Jul 25 '17 02:07 hbulgarini

still can't disable mine as well.

paigeflourin avatar Nov 12 '18 10:11 paigeflourin

you need to use sortable:

columns:[{
  sortable:false
}]

And the column is no longer clickable.

IsaackRasmussen avatar Nov 20 '18 09:11 IsaackRasmussen

columns:[{ sortable:false }]

This will disable sorting for all columns.

sbimochan avatar Apr 04 '19 09:04 sbimochan

This should work just fine. https://codepen.io/tannerlinsley/pen/XgZgeg?editors=0010

Only works if it is parent column.

sbimochan avatar Apr 04 '19 09:04 sbimochan

still can't disable mine as well.

This works for me!

https://github.com/tannerlinsley/react-table/issues/336#issuecomment-309575199

honglytech avatar Sep 17 '19 01:09 honglytech

On version 7:

{ Header: 'First Name', accessor: 'firstName', disableFilters: true, }

mmaya avatar Nov 07 '19 12:11 mmaya

On Version 7:

{
    Header: 'Some Thing',
    accessor: 'something',
    disableSortBy: true
}

In this case you disable sorting features on a column. Source: https://github.com/tannerlinsley/react-table/blob/master/docs/api.md#column-options-1

amir3code avatar Nov 26 '19 13:11 amir3code

This doesn't work on 7.0.4 was someone able to get it working?

jaekunchoi avatar May 02 '20 09:05 jaekunchoi

This doesn't work on 7.0.4 was someone able to get it working?

Everything works on 7 but is tricky.

sbimochan avatar May 02 '20 14:05 sbimochan

Why is it tricky? It's just a simple thing. I'm also having difficulty hiding columns by default whose value are empty, which also should be very simple but having difficulty getting it done. Any help here would be appreciated.

const columns = React.useMemo(
    () => [
      {
        Header: "Disclaimer Form Records",
        columns: [
{
            Header: "Price",
            accessor: "totalGroupPrice",
            disableFilters: true,
            disableSortBy: true
            // isVisible: !data[0].totalGroupPrice
          },
}

"react-table": "^7.0.0-rc.16",

AndrewAi avatar Jul 28 '20 23:07 AndrewAi

disableSortBy: true

Thanks this worked for me disableSortBy: true

Matar91 avatar Sep 29 '20 16:09 Matar91

disableSortBy: true Thanks worked for me but one thing still remain two caret signs after text remains there

Horroon avatar Nov 19 '20 15:11 Horroon

@Horroon You could use column.canSort to hide or show caret signs

Reference

sabbiu avatar Apr 28 '21 02:04 sabbiu

disableFilters: true not working in v7.7

hrithiknaha avatar Apr 28 '21 18:04 hrithiknaha

Hi, i solved my issue by:

{
        Header: 'Category',
        accessor: 'category',
        cellClass: 'text-muted w-20',
        disableSortBy: true,
 }

dahalprastut avatar May 28 '21 01:05 dahalprastut

I dont understand why we mix disable filtering and disable sorting in this issue, topic was clearly about filtering...

I can confirm disableFilters: true works on 7.7.0

roman-la avatar Oct 20 '21 09:10 roman-la

In the columns object, include the disableGlobalFilter property with a boolean value like...

 {
    Header: "First Name",
    accessor: "first_name",
    disableGlobalFilter: true, // disable global filter for this specific column
  }

My react-table version is 7.7.0

See the section Column Options at the link below

https://react-table.tanstack.com/docs/api/useGlobalFilter#table-options

image

wadoodhussaini avatar Dec 03 '21 03:12 wadoodhussaini