简体   繁体   中英

How to add filter in ag-grid Angular?

I want to implement a filter with a text box(like a search). I am trying to implement it as follows,

 this.columnDefs = [
  {
    field: 'athlete',
    filter: 'agSetColumnFilter',
  }]

The type of the field is string.

But this giving me something like this,

图像1

but I want like below where I can type and search.

图2

Can any one pls suggest me help.Thanks.

图片

You're using the agSetColumnFilter filter which allows you to select from a list of values to filter by. You need to use the agTextColumnFilter filter (see Here ).

Change your code to:

  this.columnDefs = [
  {
    field: 'athlete',
    floatingFilter: true
    filter: 'agSetColumnFilter',
  }]

Demo .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM