This is a migrated thread and some comments may be shown as answers.

Dynamically change the filter icon background colour when using kendoGridFilterMenuTemplate

1 Answer 1243 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Murray
Top achievements
Rank 1
Iron
Veteran
Murray asked on 07 May 2020, 12:25 PM

When a filter is active in a column header the background colour changes to red by default.

I would like to be able to set it to a different colour depending on the data present in the filter. Is there a way to do this? 

Thanks

1 Answer, 1 is accepted

Sort by
0
Svet
Telerik team
answered on 11 May 2020, 06:52 AM

Hi Murray,

Indeed, there isn't such built-in feature available that would allow to achieve the required behavior out-of-the-box. However what could be done as a workaround is to set a style for each column header via the headerClass input property. That will allow to differentiate between the different filter menu icons for each column and will provide a way by which the filter menus can be styled differently. Then the applied colors can be set by using some custom JavaScript at any event. Please check the following example where I demonstrate how the filter menu color can be changed on button click for the "ProductName" column following the suggestions:

https://stackblitz.com/edit/angular-uk3ecm?file=app/app.component.ts

A similar implementation can be used and the filter color can be changed on (dataStateChange) or (filterChange) event of the Grid. These events will provide access to the currently applied filters to the Grid and based on them it will be possible to change the color of the required filter menu accordingly as per the project requirements. However, such implementation would be considered custom and the developer should implement the logic within the (dataStateChange) or (filterChange) event that determines what color to set to which column menu filter under what conditions.

I hope the provided details help you to move forward with this case. Please let me know in case I can provide any further assistance on this case. Thank you.

Regards,
Svetlin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
Murray
Top achievements
Rank 1
Iron
Veteran
Answers by
Svet
Telerik team
Share this question
or