Default DropDownList to first item in Data

1 Answer 126 Views
DropDownList
Dean
Top achievements
Rank 1
Iron
Iron
Veteran
Dean asked on 22 Sep 2021, 08:44 AM

Where a DropDownList is populated dynamically, and mandatory, it makes sense for there to be an option to automatically default to the first item in the list.  Especially as there may only be one item in the list, or the first item may account for 99% of cases.

It would be great if this could be done via a simple property:  DefaultToFirst="true".

1 Answer, 1 is accepted

Sort by
0
Svetoslav Dimitrov
Telerik team
answered on 27 Sep 2021, 06:47 AM

Hello Dean,

You can still achieve the desired behavior by binding the value of the component to the FirstOrDefault() of the data collection. Depending on the business scenario this might be done in the OnInitializedAsync or the OnParametersSetAsync lifecycle hooks that the Blazor framework provides. The reason why would not like to provide this as a built-in feature is that the Telerik component should not intervene with data collection. Exposing such parameters would clutter the API and make them harder to use. 

Regards,
Svetoslav Dimitrov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
DropDownList
Asked by
Dean
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Svetoslav Dimitrov
Telerik team
Share this question
or