HeaderTemplateDirective & FilterMenuTemplateDirective produces verbose template code

2 Answers 125 Views
Grid
Jonathan
Top achievements
Rank 1
Iron
Iron
Jonathan asked on 08 Aug 2022, 06:58 AM

Hello,

I'm using FilterMenuTemplateDirective and HeaderTemplateDirective  of @progress/kendo-angular-grid in order to custom FilterMenu presentation and behaviour.

It works fines as described in the documentation.

But, in my case I need to use these directives in almost of my grid columns, then it produces a lot of repetitive code as in the example below (see code lines in red and run live code here)

Please, I would be delighted to know what is the best approach to avoid repeating the same code in this case ?

Thanks for your help.
Jonathan.

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Yanmario
Telerik team
answered on 10 Aug 2022, 12:49 PM

Hi Jonathan,

What can be done to reduce code repetivnes, in this case, is to define the Grid columns dynamically and use only one kendoGridFilterMenuTemplate as demonstrated in the following example:

https://stackblitz.com/edit/angular-av8sby-kaviy8?file=src%2Fapp%2Fapp.component.ts

Another option would be to wrap the Grid component and reuse it. Here is a basic example of such an approach:

https://stackblitz.com/edit/grid-wrapper-component?file=app%2Fgrid-wrapper%2Fgrid-wrapper.component.ts

I hope both suggestions help.

Regards,
Yanmario
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


0
Jonathan
Top achievements
Rank 1
Iron
Iron
answered on 10 Aug 2022, 12:59 PM

Hi Yanmario,

Thanks for you solution, its perfect !

I feel dumb now that I see your solution ! I need to be in Angular mode, no more in asp.net core !  :-)

Thx.

Jonathan.

Tags
Grid
Asked by
Jonathan
Top achievements
Rank 1
Iron
Iron
Answers by
Yanmario
Telerik team
Jonathan
Top achievements
Rank 1
Iron
Iron
Share this question
or