Clear the selection of a DropDownList

1 Answer 955 Views
DropDownList
Alumind
Top achievements
Rank 1
Alumind asked on 24 Jan 2022, 05:05 AM

Hello,

I have a page that is correctly populating a DropDownList with a list of customers as shown below:

 

 <kendo-dropdownlist for="CustomerIdValue"
                                    name="customers"
                                    filter="FilterType.Contains"
                                    placeholder="Select customer"
                                    datatextfield="Display"
                                    datavaluefield="Value"
                                    style="width: 100%;">
                    <datasource type="DataSourceTagHelperType.Custom">
                        <transport>
                            <read url="@Url.Action("CustomersInternal_GET", "User")" />
                        </transport>
                    </datasource>
                </kendo-dropdownlist>

Unfortunately the dropdownlist be default selects the first customer in its list.

I _don't_ want the dropdown to have a selected item when the page loads. In this particular form I want the user to be forced to select a customer. How do I 1) get the initial load to not select an item 2) check the user has selected a customer from the list before I enable the Submit button.

 

Yes, a user MUST be forced to actually choose a customer from the dropdownlist.

Thank you kindly!

1 Answer, 1 is accepted

Sort by
1
Stoyan
Telerik team
answered on 26 Jan 2022, 05:49 PM

Hi Peter,

To ensure the DropDownList doesn't have a value initially, I would recommend you to configure its option-label property. It will replace the null value of the Component.

 option-label="Enter a name"

Please review the following REPL for a runnable sample of the above.

Then you can use the Kendo UI Validator to prompt the user to enter a value and to prevent the form submission, if the validation fails.

I hope the information above is useful. Please don't hesitate to let me know, should further questions occur.

Regards,
Stoyan
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
Alumind
Top achievements
Rank 1
Answers by
Stoyan
Telerik team
Share this question
or