Can Anyone explain to me the structures of this codes?
For an instance .Name("products")
is the DropDownList
name, I would like to know for what are those (what do you call this (Name
, OptionLabel
, etc.)) because it really confuse me. I'm stuck in creating a cascading DropDownList
.
@(Html.Kendo().DropDownList()
.Name("products")
.OptionLabel("Select product...")
.DataTextField("ProductName")
.DataValueField("ProductID")
.DataSource(source => {
source.Read(read =>
{
read.Action("Type", "ComboBox")
.Data("filterProducts");
})
.ServerFiltering(true);
})
.Enable(false)
.AutoBind(false)
.CascadeFrom("categories")
)
<script>
function filterProducts() {
return {
categories: $("#categories").val()
};
}
</script>
<p>
<label for="orders">Orders:</label>
@(Html.Kendo().DropDownList()
.Name("orders")
.OptionLabel("Select order...")
.DataTextField("ShipCity")
.DataValueField("OrderID")
.DataSource(source => {
source.Read(read =>
{
read.Action("SubType", "ComboBox")
.Data("filterOrders");
})
.ServerFiltering(true);
})
.Enable(false)
.AutoBind(false)
.CascadeFrom("products")
)
<script>
function filterOrders() {
return {
products: $("#filterOrders").val()
};
}
</script>
.Name("orders"): This is the unique name to assign to the dropdown html element.
.OptionLabel("Select order..."): This is what the dropdown should display when no option is selected.
.DataTextField("ShipCity"): This is the property of the datasource that populates the dropdown options that should be displayed in the dropdown.
.DataValueField("OrderID"): This is the property of the bound datasource that populates the dropdown options that should be used as the value to bind to the underlying model of the view.
read.Action("SubType", "ComboBox"): This defines the Action and Controller that should be called to retrieve the collection that will populate the dropdown options
.Data("filterOrders"): this is used to assign parameters to the above read.Action method
.ServerFiltering(true):
.Enable(false): Whether or not the dropdown is enabled.
.AutoBind(false): Whether or not the dropdown should immediately bind to its dropdown datasource (or wait for the cascade from dropdown to be assigned a value)
.CascadeFrom("products"): The other dropdownlist to cascade from. If Autobind is false, then this dropdown will only bind to its options datasource once the other dropdown has been assigned a value by the user.