How to dynamically populate DropDownButtonItems

1 Answer 240 Views
DropDownButton
Paul
Top achievements
Rank 1
Paul asked on 22 Mar 2024, 09:20 PM
I'm building a TelerikDropDownButton, and I'd like to base the DropDownButtonItems on data pulled from SQL. But I don't see anything in the documentation that allows for that to happen, and I've tried in-line C# in the items node, and it cases the build to break.

Is there a way to attach a data object list to the DropDownButtonItems to generate the items dynamically?

1 Answer, 1 is accepted

Sort by
1
Accepted
Nadezhda Tacheva
Telerik team
answered on 25 Mar 2024, 02:26 PM

Hi Paul,

The DropDownButton is not a data-bound component, it uses a declarative approach for its DropDownButtonItems. Thus, it cannot accept a list of items to automatically render a set of DropDownButtonItems.

However, you can iterate through your collection and render a dedicated DropDownButtonItem for each entity. Here is an example: https://blazorrepl.telerik.com/wSaRwJPy24nNOcP958.

Regards,
Nadezhda Tacheva
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Tags
DropDownButton
Asked by
Paul
Top achievements
Rank 1
Answers by
Nadezhda Tacheva
Telerik team
Share this question
or