Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ag-Grid filter does not show up unless floating filter is on

I am building a grid with ag-grid and react I am trying to add a text filter to my grid but the filter does not show up on the grid. If I turn on floating filter it is there but not regularly.

Here is the code

type Props = {
  gridData: Array<any>;
}

type State = {}

class filteredGrid extends PureComponent<Props, State> {
  private gridOptions = {};
  static propsType = {
    gridData: ImmutablePropTypes.list
  }
  constructor(props) {
    super(props);
    gridOptions = {
      defaultColDef: { filter: true },
      columnDefs: [
        { headerName: "Location", field: 'location', filter: "agTextColumnFilter" },
      ],
      suppressMenuHide: true,
      suppressMovableColumns: true,
      enableSorting: true,
      rowSelection: 'single',
      rowDeselection: true,
      onGridReady: debounce(function (params) {
        params.api.sizeColumnsToFit();
        window.addEventListener('resize', function () {
          setTimeout(function () {
            params.api.sizeColumnsToFit();
          });
        });
      }),
      pagination: true,
      paginationPageSize: 10,
      rowClass: 'grid-row',
      gridAutoHeight: true,
      headerHeight: 50,
      rowHeight: 50,
      overlayNoRowsTemplate: '<span>No Data</span>',
    };
  }

  render(): ReactNode {
    const { gridData } = this.props;
    return (
      <div>
        <div className="ag-theme-material">
          <AgGridReact
            gridOptions={this.gridOptions}
            rowData={gridData}
          />
        </div>
      </div>
    );
  }
}

The grid has no filter and looks like this:

Grid

How can I get the filter icon that opens the filter to show up?

like image 665
Connor Avatar asked Jan 21 '26 05:01

Connor


2 Answers

I solved the issue, In order to make the filters appear I had to set the grid option enableFilter: true . I did not know this as it was never mentioned in the documentation.

like image 141
Connor Avatar answered Jan 22 '26 18:01

Connor


I had this problem today and my issue was having suppressMenu: true in my default column definition.

like image 25
dichohecho Avatar answered Jan 22 '26 19:01

dichohecho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!