I have implemented an IgxGridStyleFilter in my IgxGrid.
I have added an igxCombo inside with my custom values.
Requirement : When I click apply button on the filter (onFilteringDone event in Igx 11.0.5) I want to access the field property of the column (IgxColumn) and the updated values of IgxCombo
Hello Kaushik,
At this point we do not provide an option for getting the reference of the column in the onFilteringDone event handler if no filter is applied. What I can suggest as a workaround is to get the reference of the column while you are handling the onOpening event of IgxCombo:
HTML
<igx-grid-excel-style-filtering #esf [minHeight]="'380px'" [maxHeight]="'500px'"> ... </igx-grid-excel-style-filtering>
TYPESCRIPT
... @ViewChild('esf') public esf: IgxGridExcelStyleFilteringComponent; ... public onComboOpening() { this.currentColumnFieldName = this.esf.column?.field; } ... public onFilteringDone(args: IFilteringExpressionsTree) { console.log(this.currentColumnFieldName); } ...
I have created a small sample illustrating my suggestion, which you can find here. Please test it on your side and let me know whether you find it helpful. Keep in mind that if you update your igniteui-angular package to 11.1 or newer version you will be able to use the new filtering event of IgxGrid. Since this event is emitted before the excel style filtering dialog is closed the reference of the current column can be gotten.
Since there might be a better approach for achieving your requirement, please elaborate on what is the behavior that you are looking for when you are using igx-combo in the excel style filtering dialog, so that I can investigate it further. Could you please also provide me with a sample or code snippet of your approach for creating independent dropdowns for each column? Having a sample, which I can debug on my side, will be highly appreciated and extremely helpful for providing you with a solution as soon as possible.
Additionally, I have logged the behavior of the onFilteringDone event in our GitHub repository and you can view the issue here. Any concerns or questions that you have can be directly addressed in the issue, which will give you the opportunity to directly communicate with our development team.
In order to receive a notification whenever a new information is available please make sure that you are subscribed to the issue. This can be achieved via “Subscribe” button.
Please let me know if you need any further assistance regarding this matter.
Regards,
Viktor Kombov
Entry Level Software Developer
Infragistics, Inc.
I understand but my code needs each column to have an independent dropdown and I need those values when clicked apply.
I have already created a workaround for an independent dropdown for each column.If the $event is null then I cant determine which dropdown I need to target since it is dependent on the field of the column.
This is just an example how the reference of the column can be accessed in the onFilteringDone handler. However, you can prevent the throwing of the error if you check whether the value of args is truthy:
public onFilteringDone(args: IFilteringExpressionsTree) { if (args) { const currColumn = this.grid.getColumnByName(args.fieldName); console.log(currColumn.field); } console.log(this.combo.selectedItems()) }
Regards,Viktor KombovEntry Level Software DeveloperInfragistics, Inc.
I tried this method. There is a bug in this approach.
When you just select the dropdown and click apply this onFilteringDone event throws null in $event.
So when that happens every step further fails.
Also the igx-combo for all columns shows the same value, which is not a problem since I have a workaround for that.
Thank you for posting in our community.
The onFilteringDone event returns the filtering expressions tree of the column, which includes the name of the column field. Therefore, if you have the name of the column field, you can access the column and its properties with the getColumnByName method of the IgxGrid:
… @ViewChild("grid1", { read: IgxTreeGridComponent, static: true }) public grid: IgxTreeGridComponent; … public onFilteringDone(args) { const currColumn = this.grid.getColumnByName(args.fieldName); console.log(currColumn.field); }
Regarding your second requirement, the selected items of the combo can be accessed with its selectedItems method:
… @ViewChild("combo") public combo: IgxComboComponent; … public onFilteringDone(args) { console.log(this.combo.selectedItems()) }
I created a small sample illustrating my suggestion, which you can find here. Please test it on your side and let me know whether you find it helpful.
Please let me know if you have any further questions and concerns.