React-bootstrap-table2: Programmatically filter hidden columns

Created on 18 Sep 2018  路  6Comments  路  Source: react-bootstrap-table/react-bootstrap-table2

Is it possible to filter hidden columns?

Most helpful comment

EDIT: This does not work as well as I had thought--the programmatic filter remains BUT the column header CSS seems to over-ride the filter CSS and essentially forces the table header height to allow for the "invisible" table sort element. This is visually undesirable, and the added white space is a live area (sorts the table columns if you click in it). I'll keep working to figure out how to fix the CSS on it.

screen shot 2018-11-29 at 4 51 43 pm

Update for anyone else who might be looking how to do this:

  1. Set CSS property "visibility" to "hidden" on the following 3 styles: column, column header, filter.
  2. Set style height for filter to 0px
  3. Set style width for column to 0

Works like a charm! See code below for example (places to set CSS are marked with double *).

Link for more info about CSS visibility

{
    dataField: 'hideme',
    text: 'HideMe',
    headerStyle: (column, colIndex) => {
        **return { width: 0 , 'visibility': 'hidden'}**
    },
    filter: multiSelectFilter({
        options: selectHideMeOptions,
        defaultValue: this.state.columnFilter7,
            getFilter: (filter) => {
                this.setState.columnFilter7 = filter
            },
            placeholder: 'Select',
            **style: {'visibility': 'hidden','height':'20px'}**
                }),
    **style: {'visibility': 'hidden'}**
}

All 6 comments

@paulalcabasa we don't support this feature but you can implement it by yourself, just control the colums props on BootstrapTable thanks

Hi @paulalcabasa were you able to figure out how to make this work? I'd like to do the same thing in my code!

EDIT: This does not work as well as I had thought--the programmatic filter remains BUT the column header CSS seems to over-ride the filter CSS and essentially forces the table header height to allow for the "invisible" table sort element. This is visually undesirable, and the added white space is a live area (sorts the table columns if you click in it). I'll keep working to figure out how to fix the CSS on it.

screen shot 2018-11-29 at 4 51 43 pm

Update for anyone else who might be looking how to do this:

  1. Set CSS property "visibility" to "hidden" on the following 3 styles: column, column header, filter.
  2. Set style height for filter to 0px
  3. Set style width for column to 0

Works like a charm! See code below for example (places to set CSS are marked with double *).

Link for more info about CSS visibility

{
    dataField: 'hideme',
    text: 'HideMe',
    headerStyle: (column, colIndex) => {
        **return { width: 0 , 'visibility': 'hidden'}**
    },
    filter: multiSelectFilter({
        options: selectHideMeOptions,
        defaultValue: this.state.columnFilter7,
            getFilter: (filter) => {
                this.setState.columnFilter7 = filter
            },
            placeholder: 'Select',
            **style: {'visibility': 'hidden','height':'20px'}**
                }),
    **style: {'visibility': 'hidden'}**
}

Out of the box support for this would be very helpful!

Thanks a lot @mkwenzel !

However, I ended up replacing all your styles for simply display: 'none', since I couldn't get bot the header and each cell to be _really_ hidden.

EDIT: This does not work as well as I had thought--the programmatic filter remains BUT the column header CSS seems to over-ride the filter CSS and essentially forces the table header height to allow for the "invisible" table sort element. This is visually undesirable, and the added white space is a live area (sorts the table columns if you click in it). I'll keep working to figure out how to fix the CSS on it.

screen shot 2018-11-29 at 4 51 43 pm

Update for anyone else who might be looking how to do this:

  1. Set CSS property "visibility" to "hidden" on the following 3 styles: column, column header, filter.
  2. Set style height for filter to 0px
  3. Set style width for column to 0

Works like a charm! See code below for example (places to set CSS are marked with double *).

Link for more info about CSS visibility

{
  dataField: 'hideme',
  text: 'HideMe',
  headerStyle: (column, colIndex) => {
      **return { width: 0 , 'visibility': 'hidden'}**
  },
  filter: multiSelectFilter({
      options: selectHideMeOptions,
      defaultValue: this.state.columnFilter7,
          getFilter: (filter) => {
              this.setState.columnFilter7 = filter
          },
          placeholder: 'Select',
          **style: {'visibility': 'hidden','height':'20px'}**
              }),
  **style: {'visibility': 'hidden'}**
}

Yes, If you want to display absolutely nothing, you need to set style and headerStyle options from {'visibility': 'hidden'} to {'display': 'none'}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

primakashi picture primakashi  路  3Comments

sudravi picture sudravi  路  3Comments

saifulss picture saifulss  路  4Comments

cnav007 picture cnav007  路  4Comments

josefheld picture josefheld  路  3Comments