Completed
Last Updated: 13 Oct 2023 10:52 by ADMIN
Release R1.2024-Increment.1(15.Nov.2023)
Vladyslav
Created on: 25 Nov 2022 10:12
Category: TreeView
Type: Bug Report
2
Setting the Id configuration of a TreeView node does not add the data-id attribute

Bug report

The TreeView rendering in UI for ASP.NET MVC and UI for ASP.NET Core are not consistent. Setting the Id configuration for an item in UI for ASP.NET MVC renders a data-id attribute, that is missing in UI for ASP.NET Core.

Reproduction of the problem

  1. Use the following TreeVIew definition
@(Html.Kendo().TreeView()
        .Name("treeview-kendo")
        .TemplateId("treeview")
        .Checkboxes(c=>c.CheckChildren(true))
        .Items(treeview =>
        {
            treeview.Add()
                .Text("My Documents")
                .Id("MyId1");

            treeview.Add()
                .Text("My Documents 2")
                .Id("MyId2");                
        })
)

Current behavior

When using the UI for ASP.NET Core the rendered <li> element does not have the data-id attribute that is present in UI for ASP.NET MVC

<li role="treeitem" class="k-item k-treeview-item k-first" data-uid="a3c937fd-1c4a-46a6-81e1-e53e1a2aeb6e" aria-checked="false" aria-selected="false" aria-expanded="false" data-expanded="false" aria-setsize="2" aria-level="1">
  <div class="k-treeview-top k-treeview-top">
    <span class="k-checkbox-wrapper" role="presentation">
      <input id="_a3c937fd-1c4a-46a6-81e1-e53e1a2aeb6e" aria-hidden="true" type="checkbox" tabindex="-1" class="k-checkbox k-checkbox-md k-rounded-md">
    </span>
    <span class="k-treeview-leaf k-in">
      <span class="k-treeview-leaf-text">My Documents</span>
    </span>
  </div>
</li>

Expected/desired behavior

Rendering should be consistent and the data-id attribute added in UI for ASP.NET Core.

Workaround

Use the HtmlAttributes configuration to add the data-id attribute

treeview.Add()
    .HtmlAttributes(new {data_id = "MyId1"})
    .Text("My Documents")
    .Id("MyId1");

Environment

  • Kendo UI version: 2022.3.1109
  • Browser: [all]
  • Further details available in ticket 1588455
0 comments