### Bug report
The DropDownTree TagHelper does not serialize the "Value" and "Id" properties when it is configured for local data binding (using the "bind-to" option).
### Reproduction of the problem
1) Use the following DropDownTree TagHelper configuration:
//Controller
public IActionResult Index()
{
List<DropDownTreeItemModel> ddtData = new List<DropDownTreeItemModel>()
{
new DropDownTreeItemModel() { Id = "1", Text = "Option 1", Value = "S1" },
new DropDownTreeItemModel() { Id = "2", Text = "Option 2", Value = "S2",
Items = new List<DropDownTreeItemModel>()
{
new DropDownTreeItemModel() { Id = "3", Text = "Option 3", Value = "S3" }
}
}
};
ViewBag.StateTreeListData = ddtData;
return View();
}
// View
<kendo-dropdowntree name="StateLocationDropDownTree" style="width: 100%"
height="500px"
auto-width="true"
bind-to="(IEnumerable<DropDownTreeItemModel>)ViewBag.StateTreeListData">
</kendo-dropdowntree>
2) When the DropDownTree is loaded, inspect its initialization script - the "value" and "id" properties are "null".
### Expected/desired behavior
The "Id" and "Value" properties must be serialized as the rest of the DropDownTreeItemModel properties.
### Environment
* **Telerik UI for ASP.NET Core version: 2024.2.514
* **Browser: [all]
DropDownTreeFor with checkboxes enabled is not binding to model value after postback.
Use the following definition of a DropDownTreeFor HtmlHelper in a plain HTML form, where MySelectedIds is int[]
:
@(Html.Kendo().DropDownTreeFor(m => m.MyClass.MySelectedIds)
.Checkboxes(checkboxes => checkboxes
.CheckChildren(false)
)
.DataTextField("MyText")
.DataValueField("MyId")
.AutoClose(false)
.CheckAll(true)
.DataSource(dataSource => dataSource
.Custom()
.Transport(t => t
.Read(r => r.Url("/api/items"))
)
)
)
The DropDownTree is bound to the model value on page load, but on successful form submission and returning the model the DropDownTree is not bound to the data. Refer to ticket 1648108 for a runnable example.
The DropDownTree should be bound to the model value after successful form submission.
Bind the model to a string[]
instead of int[]
.
### Bug report
The DropDownTree TagHelper with enabled checkboxes does not submit the selected options when it is bound to a Model property.
### Reproduction of the problem
1. Define a DropDownTree TagHelper as a form editor and and enable its checkboxes.
2. Bind the editor to a Model property (an array of integers).
3. Submit the form and examine the submit request payload. The values of the selected items are missing.
//Model
public class TestFormModelClass
{
public int[] MonthsSelectedIds { get; set; }
}
//View
@model TestFormModelClass
<form method="post">
<kendo-dropdowntree for="MonthsSelectedIds"
check-all="true"
datatextfield="Month"
datavaluefield="Id">
<hierarchical-datasource type="DataSourceTagHelperType.Custom">
<schema>
<hierarchical-model id="id"></hierarchical-model>
</schema>
<transport>
<read url="/api/items" />
</transport>
</hierarchical-datasource>
<checkboxes check-children="false" name="CheckedMonths" enabled="true" />
</kendo-dropdowntree>
<button type="submit">Save</button>
</form>
### Expected/desired behavior
When the DropDownTree TagHelper with checkboxes is used as a form editor, the values of the selected items must be submitted as expected to the server.
### Workaround
Use the HtmlHelper version of the DropDownTree
### Environment
* **Telerik UI for ASP.NET Core version: 2024.1.319
* **Browser: [all]
DropDownTree TagHelper throws error when the BindTo configuration is set.
bind-to
TagHelper attribute.Setting the bind-to TagHelper attribute produces the following error
One or more errors occurred. (Object reference not set to an instance of an object.)
Setting the bind-to should not produce a run-time error.
DropDownTree is not serialized correctly when declared in the Template component.
The DropDownTree is not serialized correctly when declared in the Template component.
The DropDownTree is not serialized correctly when declared in the Template component.
Is it possible to implement an option that enables the auto-expanding of the parent items while filtering?
This functionality is available in Kendo UI for Angular:
For example:
DropDownTreeItemModel does not properly pass its HtmlAttributes members on populating DropDownTree with BindTo()
In .Net Core application, implement the following view:
@(Html.Kendo().DropDownTree()
.Name("kendoTreeItems")
.BindTo((IEnumerable<DropDownTreeItemModel>)ViewBag.Items)
)
and the following controller:
public IActionResult Index()
{
ViewBag.Items = GetItems();
return View();
}
public IEnumerable<DropDownTreeItemModel> GetItems()
{
IDictionary<string, string> attributes = new Dictionary<string, string>
{
{ "style", "background: red" }
};
List<DropDownTreeItemModel> items = new List<DropDownTreeItemModel>
{
new DropDownTreeItemModel { Text = "Item 1", HtmlAttributes = attributes },
new DropDownTreeItemModel { Text = "Item 2", HtmlAttributes = attributes },
new DropDownTreeItemModel { Text = "Item 3", HtmlAttributes = attributes },
new DropDownTreeItemModel { Text = "Item 4", HtmlAttributes = attributes },
};
return items;
}
The HTML attributes will not be passed to the DropDownTree items.
The HTML attributes should be passed and present in the DropDownTree items.