Unplanned
Last Updated: 23 Apr 2024 12:08 by ADMIN
Laurie
Created on: 09 Apr 2024 19:30
Category: DropDownTree
Type: Bug Report
0
DropDownTree TagHelper renders input instead of select element when checkboxes are enabled

### 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]

4 comments
ADMIN
Aleksandar
Posted on: 23 Apr 2024 12:08

Hello Laurie,

I have been investigating the issue related to the DropDownTree not binding to the model when the submission of the form is successful. Indeed, I can confirm this is another bug on our end and I have logged another item on your behalf:

https://feedback.telerik.com/aspnet-core-ui/1649708-dropdowntreefor-with-checkboxes-enabled-is-not-binding-to-model-value-after-postback

Here is the GitHub item if you prefer to track the status of the item via GitHub:

https://github.com/telerik/kendo-ui-core/issues/7807

As a workaround, until the issue is fixed, I can suggest changing the type of the collection to which the component is bound to - from int[] to string[]. With that update the component will bind to the returned data. I have attached the updated sample application for you to review.

Regards,
Aleksandar
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.
Attached Files:
ADMIN
Mihaela
Posted on: 17 Apr 2024 12:31

Hello Laurie,

Thank you for sharing a runnable sample that replicates the described issue when using the HtmHelper version of the DropDownTree component.

We will discuss the unexpected behavior with the developers, and I follow up with more information regarding the matter.

Meanwhile, you can explore the TreeView component that supports checkboxes. Another option is to utilize the template options of the MultiSelect editor to display its items with checkboxes, as per the following example:

https://netcorerepl.telerik.com/wyOeuCPf35D8l72H35

 

Regards,
Mihaela
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.
Laurie
Posted on: 10 Apr 2024 20:59
Also, if there's another control that would enable me to pop up a checkboxlist, I would be happy to use that. Please advise.
Laurie
Posted on: 10 Apr 2024 20:48

I tried the HtmlHelper version and the selected values ARE reflected in the OnPost method. However, they are not reflected in the DropDownTree form control after the post. (You'll see that the values selected are displayed in an unordered list but not in the control.)

6 Items selected before posting:

Items reflected in bullet list but not in control after posting:

 

Again, attaching the example.

Attached Files: