8

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!

tereško
  • 58,060
  • 25
  • 98
  • 150
Jude Duran
  • 2,195
  • 2
  • 25
  • 41

2 Answers2

8

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. :)

Jude Duran
  • 2,195
  • 2
  • 25
  • 41
7

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

Petur Subev
  • 19,983
  • 3
  • 52
  • 68
  • 1
    Hi Pechka, could you please tell me how this ToClientTemplate() works? Cant find any documentation about this one. Thanks! – Jude Duran Feb 14 '13 at 03:15
  • Thanks Pechka! It worked. Ijust removed the "Render()" function. I posted my final solution. :) – Jude Duran Feb 15 '13 at 03:37