I am using the Scheduler and making a custom edit screen. I am following the example here.
Each scheduled event can have a category. These are selectable via dropdown. Consider the following portion of the template:
<div class="k-edit-label">
<label for="category">Category</label>
</div>
<div data-container-for="category" class="k-edit-field">
<!-- HERE IS WHERE THE DROPDOWN IS -->
</div>
In the example linked, a simple <select> element is used. But I am looking to add a real Kendo dropdown, not a basic select. So I defined it as follows:
var categoryEditorDropdown = Html.Kendo().DropDownList()
.AutoBind(true)
.BindTo(categories)
.DataTextField(nameof(Category.Description))
.DataValueField(nameof(Category.Id))
.HeaderTemplate("Custom defined template which is why I need this over a select")
.OptionLabelTemplate("Custom defined template which is why I need this over a select")
.Name("category")
.ToClientTemplate();
Back to my editor template, for the commented green line I tried both the following, and both gave template errors:
<div data-container-for="category" class="k-edit-field">
<!-- Both fail with a template error -->
@categoryEditorDropdown
@Html.Raw(categoryEditorDropdown)
</div>
Next, I made a separate script:
<script id="editEventCategoryTemplate" type="text/x-kendo-template">
// Tried both of these and again both fail when editing the event
@categoryEditorDropdown
@Html.Raw(categoryEditorDropdown)
</script>
And I updated the editor to try and use it:
<div data-container-for="category" class="k-edit-field">
#= kendo.render(kendo.template($("\\#editEventCategoryTemplate").html())) #
</div>
For both tests here the page renders but then throws the same invalid template error when I try to edit an event.
How can I embed templates into each other. I need far more than category here. There are 6 templates in total needed for 6 different fields.