Change background of Item in dropdownlist

1 Answer 97 Views
DropDownList
Supriya
Top achievements
Rank 1
Supriya asked on 04 Oct 2021, 12:43 PM | edited on 05 Oct 2021, 07:09 AM

I want to highlight or style  a particular item from the dropdownlist on some condition. but i don't find anything .

Could anyone suggest how I could customize it?

Adding some more information. I want to highlight the item 2021 from the list

https://i.stack.imgur.com/67R49.png

Supriya
Top achievements
Rank 1
commented on 05 Oct 2021, 07:02 AM

does focusItemAt can be used for the purpose?

1 Answer, 1 is accepted

Sort by
0
Stoyan
Telerik team
answered on 06 Oct 2021, 10:13 AM

Hi Supriya,

Thanks for the provided information.

Yes. In order to highlight an item from the list, the DropDownList provides a focusItemAt method that allows the developer to focus an item at a given index.

Please see the following StackBlitz demo that demonstrates the desired behavior:

https://stackblitz.com/edit/angular-9znsy1-i9rrge

To style a given item, the DropDownList provides templates that enable you to customize the elements in the popup. In this particular scenario, the Item Template can be used to target the items and style them as per project requirements.

I've prepared a short StackBlitz demo that demonstrates how the Item Template can be used and will highlight the last item based on a condition:

https://stackblitz.com/edit/angular-9znsy1

I hope this points you in the right direction.

Regards,
Stoyan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
DropDownList
Asked by
Supriya
Top achievements
Rank 1
Answers by
Stoyan
Telerik team
Share this question
or