Custom tool using templates in Editor

1 Answer 15 Views
Editor
Eric
Top achievements
Rank 1
Eric asked on 30 Apr 2025, 08:21 PM

I am trying to implement a custom tool in the Kendo Editor, following demo/doc implementation and always getting a typeError of some form whenever the custom tool uses a kendo template.  For example:

@(Html.Kendo().Editor()
    .Name("editor")
    .Tools(tools => {
            tools
        .Clear()
        .Bold()
        .Italic()
        .CustomTemplate(temp => temp.Template(
                Html.Kendo().DropDownList()
                    .Name("ddl1")
                    .DataTextField("Text")
                    .DataValueField("Value")
                    .BindTo(new List<object>
                    {
                        new { Text = "text 1", Value = "Value 1" },
                        new { Text = "text 2", Value = "Value 2" },
                        new { Text = "text 3", Value = "Value 3" },
                        new { Text = "text 4", Value = "Value 4" }
                    })
                    .ToClientTemplate()
                    .ToHtmlString()
                ));
    })
)

In this case the error is as follows:

Uncaught TypeError: Cannot read properties of null (reading 'length')

1 Answer, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 05 May 2025, 10:17 AM

Hi Eric,

If you specify the Name() option of the custom tool, the issue should be resolved:

@(Html.Kendo().Editor()
    .Name("editor")
    .Tools(tools => {
            tools
        .Clear()
        .Bold()
        .Italic()
        .CustomTemplate(temp => temp.Name("customDDL").Template(
                Html.Kendo().DropDownList()
                    .Name("ddl1")
                    .DataTextField("Text")
                    .DataValueField("Value")
                    .BindTo(new List<object>
                    {
                        new { Text = "text 1", Value = "Value 1" },
                        new { Text = "text 2", Value = "Value 2" },
                        new { Text = "text 3", Value = "Value 3" },
                        new { Text = "text 4", Value = "Value 4" }
                    })
                    .ToClientTemplate()
                    .ToHtmlString()
                ));
    })
)

Regards,
Mihaela
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Editor
Asked by
Eric
Top achievements
Rank 1
Answers by
Mihaela
Telerik team
Share this question
or