How can I hide the filter icon in Ag-grid?
Asked Answered
C

9

7

I'm trying to remove the filter icon in ag-grid whilst keeping the filtering box

Right now I'm trying to use pure css to hide the icon which in webpack just adds the aria-hidden="true"

CSS I've tried

* /deep/ div.ag-floating-filter-button{
    display:none !important;   
}

Trying to remove this icon

Icon

I either want to completely remove the grid icon using columnsAPI or find a way with CSS to disable the icon truely.

Chancellorship answered 29/1, 2018 at 21:14 Comment(0)
P
6

This page in the docs describes how to change the icons. I suggest that you change them to an empty string, either in the gridOptions or in a css file. here is the gridOptions way with a plunker:

<ag-grid-angular
    ...
    [icons]="icons"
    ...
    ></ag-grid-angular>


this.icons = {
  filter: ' '
}
Purulence answered 30/1, 2018 at 15:55 Comment(0)
C
25

Use floatingFilter and check floatingFilterComponentParams. You can hide the filter button by adding this in columnDefs in gridOptions like below

gridOptions = {
  floatingFilter: true
  columnDefs:[{
    ...
    suppressMenu: true,
    floatingFilterComponentParams: {suppressFilterButton:true}
    ...
  }]
}
Cryometer answered 14/8, 2018 at 9:0 Comment(0)
P
6

This page in the docs describes how to change the icons. I suggest that you change them to an empty string, either in the gridOptions or in a css file. here is the gridOptions way with a plunker:

<ag-grid-angular
    ...
    [icons]="icons"
    ...
    ></ag-grid-angular>


this.icons = {
  filter: ' '
}
Purulence answered 30/1, 2018 at 15:55 Comment(0)
L
4

Inside of your 'columnDef' array, you should add floatingFilterComponentParams: {suppressFilterButton: true}. Also if you want to remove menu button at top of your column, you can simply create an 'icons' array and bind it to the ag-grid as an option.

What i mean:

columnDef: [
    ...
    floatingFilterComponentParams: { suppressFilterButton: true }
]

and to remove icons:

icons = {
    menu: ' ',
    filter: ' ' //optional, we have already disabled it above.
}

then

<ag-grid-angular
    ...
    [icons]="icons",
    [floatingFilter]="true">
</ag-grid-angular>
    
Liebig answered 17/3, 2020 at 5:12 Comment(1)
This actually answers the OP's question specifically - the actual marked answer is a bit of a convoluted way to remove the functionality.Ronni
B
3

You can deactivate the filter icon by two ways.

1.) First way: global dactivation

Add enableFilter: false to you gridoptions.

gridOptions = {
  // turn off filtering
  enableFilter: true,
  ...
  columnDefs: [
    ...    
  ]
}

2.) Second way: disable per column

Add suppressFilter: true to column definition to turn off filter for this column.

gridOptions = {
    // turn on filtering
    enableFilter: true,
    ...
    columnDefs: [
        {headerName: "Athlete", field: "athlete", filter: "agTextColumnFilter"}, // text filter
        {headerName: "Age",     field: "age",     filter: "agNumberColumnFilter"}, // number filter
        {headerName: "Sport",   field: "sport",   suppressFilter: true} // NO filter
    ]
}

For more information read official ag-grid documentation.

Binny answered 29/1, 2018 at 22:41 Comment(2)
I want the text box filter, I don't want that little funnel icon to exist at all on the pageChancellorship
It would be really nice if you can remove your comment // turn off filtering or change enableFilter: false from your first way of implementation. Such misleading it is. Also this should be accepted answer.Scavenger
S
1

For me the following css worked:

.ag-icon-filter {display: none;}
Soar answered 28/11, 2020 at 15:21 Comment(1)
.ag-filter-icon { display: none; } is betterHamid
S
1

We have to use the below two properties to disable icons

suppressMenu: true,
floatingFilterComponentParams: { suppressFilterButton: true }

const defaultColDef = {
        sortable: true,
        editable: false,
        flex: 1,
        filter: true,
        floatingFilter: true,
        suppressMenu: true,
        floatingFilterComponentParams: { suppressFilterButton: true },
    };

 <AgGridReact
      columnDefs={columnDefs}
      rowData={rowData}
      defaultColDef={defaultColDef}
      onGridReady={onGridReady}
 ></AgGridReact>
Som answered 2/6, 2022 at 6:44 Comment(1)
Worked for me too in React GridAcid
Z
0

To hide the filter icon on a particular column, add:

menuTabs: []

to the column definition.

Zito answered 3/12, 2018 at 16:2 Comment(0)
F
0

To remove all filter icons but still keep the default filter functionality in ag-grid, you can use the following configuration for your column definitions. This example shows how to configure a column to use a text filter without displaying the filter icon:

{ 
  headerName: 'field name', 
  field: 'field', 
  flex: 12, 
  filter: 'agTextColumnFilter',
  floatingFilter: true,
  suppressMenu: true, 
  sortable: true, 
  suppressHeaderFilterButton: true,
  floatingFilterComponentParams: { suppressFilterButton: true },
  filterParams: {
    textMatcher: ({ value, filterText }: { value: string, filterText: string }) => value.toLowerCase().includes(filterText.toLowerCase()),
    filterOptions: ['contains'], 
    suppressAndOrCondition: true,
    suppressFilterButton: true 
  }
}

Explanation:

  • suppressMenu: true: This hides the filter menu icon.
  • suppressHeaderFilterButton: true: This hides the filter button in the header.
  • floatingFilterComponentParams: { suppressFilterButton: true }: This hides the floating filter button.
  • filterParams.suppressFilterButton: true: This hides the filter button within the filter component.

With these settings, the filter functionality remains active, but all filter icons are hidden from the UI.

Fascinate answered 30/9, 2024 at 16:4 Comment(0)
P
-3

columnDefs: [ {headerName: "Athlete", field: "athlete", filter: "agTextColumnFilter",floatingFilterComponentParams: {suppressFilterButton:true}}]

Pliocene answered 30/1, 2019 at 3:22 Comment(1)
You don't even close your first bracket, besides it's better to explain a bit instead of just a line of code.Rothenberg

© 2022 - 2025 — McMap. All rights reserved.