Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Render kendo control inside kendo template (Razor)

Is it possible to render a kendo control inside a Kendo Template? Something like this one?

<script id="treeview-template" type="text/kendo-ui-template">  
 @{Html.Kendo().AutoComplete()
 .Name("test")
 .Render();
 }
</script>

Thanks in advance!

like image 868
Jude Duran Avatar asked Feb 13 '13 06:02

Jude Duran


2 Answers

Thanks for the help Pechka! ToClientTemplate() extension method did the job.

<script id="treeview-template" type="text/kendo-ui-template">
         # var ctrlid= item.ControlId; #

         @(Html.Kendo().AutoComplete()
         .Name("#=ctrlid#")
         .ToClientTemplate()
         )
</script>

But for some reason, when I put "item.ControlId" directly at the name property, it can't render the control. So i tried storing it in a variable and used that on the name property and it worked. :)

like image 177
Jude Duran Avatar answered Nov 16 '22 19:11

Jude Duran


Yes you can, just do not forget to call the ToClientTemplate method at the end. This method should be available for any Kendo widget.

like image 7
Petur Subev Avatar answered Nov 16 '22 17:11

Petur Subev