You can set the text property of the comboBox. .Text(Model.SelectedDealer)
Setting initial value in a Kendo UI Cascading Combobox with server filtering
-
29-06-2022 - |
题
I need to make a cascading combobox with server filtering but I'm having trouble setting the initial value.
The dropdownlist on which the combobox depends looks like this:
@(Html.Kendo().DropDownListFor(model => model.SelectedCompany)
.Name("UserDetailSelectedCompany")
.HtmlAttributes(new { style = "width:115px;" })
.BindTo(Model.CompanyList)
.Value(Model.SelectedCompany))
Where:
model.SelectedCompany
is astring
- Name attribute is set because I need that in the combobox (I've read on the Kendo UI forums I'm not supposed to specify it, but I don't know how to do the cascading combobox without it)
Model.CompanyList
is aList<string>
An here's the combobox:
@(Html.Kendo().ComboBoxFor(model => model.SelectedDealer)
.Name("UserDetailSelectedDealer")
.DataTextField("Name")
.DataValueField("ID")
.HtmlAttributes(new { style = "width:325px" })
.Filter(FilterType.Contains)
.AutoBind(false)
.Enable(false)
.MinLength(3)
.DataSource(source => source.Read(read => read.Action("GetDealers", "Administration").Data("Administration.GetUserDealerParameters"))
.ServerFiltering(true))
.CascadeFrom("UserDetailSelectedCompany")
.SelectedIndex(Model.SelectedDealer.ID))
Where:
model.SelectedDealer
is aDealer
Dealer
class contains aName
(string) and anID
(int)- MVC action GetDealers return a JSON converted
List<Dealer>
Does anyone have an example that demonstrate how I can get this to work? The Kendo UI doc has example for a cascading combobox, server filtering and setting initial value, but not for the 3 at same time.
解决方案
不隶属于 StackOverflow