0
votes

I am making a table in angular2 using ag-grid.

i have several columns and it is possible to filter on each column. (I use custom filter) For further development of my application i need an id of the filter field.

My rows are like this:

    createColumnDefs()  {
    this.columnDefs =[
        { headerName: "ID", field: "id", width:80, filterFramework:{

            component: PartialMatchFilterComponent,
            moduleImports: [FormsModule]
        }},
        { headerName: "Extern id", field: "externalRefId", width:150, filterFramework:{

            component: PartialMatchFilterComponent,
            moduleImports: [FormsModule]
        }},
        { headerName: "Name", field: "customerLastName", width:80,filterFramework:{

            component: PartialMatchFilterComponent,
            moduleImports: [FormsModule]
        }}
    ]
}

For example the user select the Name field to filter. I want to know that the user selected Name field. How can i check which filter field the user has chosen (for example: show in the console.log() )

1

1 Answers

1
votes

You can provide extra data to your components by supplying params - for example, with a filter you can use filterParams:

filterFramework: {
    component: PartialMatchFilterComponent,
    moduleImports: [FormsModule]
},
filterParams: {
    field: "name"
},

Then in the agInit method you'll be able to pull this information off for later use:

agInit(params:IFilterParams):void {
    console.log(params.field);