This is a migrated thread and some comments may be shown as answers.

Kendo control in ClientEditTemplate

1 Answer 374 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dina
Top achievements
Rank 1
Dina asked on 19 Mar 2017, 01:35 AM

 When I use EditorTemplate in a grid inside ClientDetailTemplateId I get "Invalid template" error due to

1. In EditorTemplate you cannot use # or you should double it ## this is clear

2. I need to user kendo control in EditorTemplate and I try to use ToClientTemplate() so kendo convert html for valid for EditorTemplate  like

@Html.Kendo().DropDownListFor(m => m.Person).ToClientTemplate()

But I still get error because kendo clause above converts into

<input id="Person" name="Person" style="width:100%;" type="text" value="" />

<script>jQuery(function(){jQuery("#Person").kendoDropDownList({"autoBind":true,"dataTextField":"FullName","dataValueField":"PersonId","dataSource":{"transport":{"read":{"url":"/Administration/Students_Read","data":function() { return kendo.ui.DropDownList.requestData(jQuery("#Person")); }},"prefix":""},"serverFiltering":true,"filter":[],"schema":{"errors":"Errors"}}});});</script></div>' Generated code:'var $kendoOutput, $kendoHtmlEncode = kendo.htmlEncode;with(data){$kendoOutput='<input data-val="true" data-val-required="The RegisterGroupId field is required." id="RegisterGroupId" name="RegisterGroupId" type="hidden" value="" /><div class="k-edit-label">    <label for="Person">Person</label></div><div class="editor-field">    <input id="Person" name="Person" style="width:100%;" type="text" value="" /><script>jQuery(function(){jQuery("';Person").kendoDropDownList({"autoBind":true,"dataTextField":"FullName","dataValueField":"PersonId","dataSource":{"transport":{"read":{"url":"/Administration/Students_Read","data":function() { return kendo.ui.DropDownList.requestData(jQuery(";$kendoOutput+='Person")); }},"prefix":""},"serverFiltering":true,"filter":[],"schema":{"errors":"Errors"}}});});</script>

I believe problem in jQuery("#Person") having hash. But it is a kinda result of ToClientTemplate() where I expect proper template for ClientTemplat

 

I can workaround it using onEdit event of I grid and using kendo UI manually to make kendo control

(like <input id="Person" name="Person" style="width:100%;" type="text" value="" /> in EditorTemplate and JQuery in onEdit) but it is a inconvenience. Whole thing of kendo for mvc in ability to use mvc control in view

1 Answer, 1 is accepted

Sort by
0
Dina
Top achievements
Rank 1
answered on 19 Mar 2017, 01:40 AM

UPDATE

Generated script for some reason consist of 2 <script> clauses one with jQuery("';Person") and one with jQuery("#Person")

Tags
Grid
Asked by
Dina
Top achievements
Rank 1
Answers by
Dina
Top achievements
Rank 1
Share this question
or