telerik / kendo-ui-core

An HTML5, jQuery-based widget library for building modern web apps.
http://www.telerik.com/kendo-ui
Other
2.54k stars 1.9k forks source link

Checkboxes property throws invalid template error #5367

Closed kendo-bot closed 10 months ago

kendo-bot commented 5 years ago

Bug report

When the Kendo UI TreeView (DropDownTree as well) is nested inside a template and the Checkboxes(true) property is set, Invalid Template error is thrown.

Expected/desired behavior

The templates of the Checkboxes have to be automatically escaped when the widget is nested inside a template.

Reproduction of the problem

<script type="text/x-kendo-template" id="template">

   @(Html.Kendo().TreeView()
    .Name("treeview")
    .Checkboxes(true)
    .Items(treeview =>
    {
        treeview.Add().Text("My Web Site")
            .SpriteCssClasses("folder")
            .Expanded(true)
            .Checked(true)
            .Items(root =>
            {
                root.Add().Text("images")
                    .Expanded(true)
                    .SpriteCssClasses("folder")
                    .Items(images =>
                    {
                        images.Add().Text("logo.png")
                            .SpriteCssClasses("image");

                        images.Add().Text("body-back.png")
                            .SpriteCssClasses("image");

                        images.Add().Text("my-photo.jpg")
                            .SpriteCssClasses("image");
                    });

                root.Add().Text("resources")
                    .Expanded(true)
                    .SpriteCssClasses("folder")
                    .Items(resources =>
                    {
                        resources.Add().Text("pdf")
                            .Expanded(true)
                            .SpriteCssClasses("folder")
                            .Items(pdf =>
                            {
                                pdf.Add().Text("brochure.pdf")
                                    .SpriteCssClasses("pdf");

                                pdf.Add().Text("prices.pdf")
                                    .SpriteCssClasses("pdf");
                            });
                    });
            });
    }).ToClientTemplate()
)

</script>

function showDetails(e) {
    e.preventDefault();
    var detailsTemplate = kendo.template($("#template").html());
    var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
    var wnd = $("#Details").data("kendoWindow");
    wnd.content(detailsTemplate(dataItem));
    $("#SendArtifactId").val(dataItem.ArtifactId);
    wnd.center().open();
}

Environment

CecoMilchev commented 5 years ago

As a temporary workaround, the checkboxes could be declared via a template:

.Checkboxes(c=>c.Template("<input type='checkbox' value='true' />"))

aleksandarevangelatov commented 10 months ago

The behavior is no longer reproducible. Here are two sample REPLs (v2023.2.1010) rendering a TreeView/DropDownTree in a ClientTemplate, with checkboxes enabled: