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

Dynamically Create templates in mvc 4

1 Answer 117 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
sirisha
Top achievements
Rank 1
sirisha asked on 12 Nov 2013, 05:51 AM
Hi team,

I want create Dynamic templates.In the below link sample showing the static template.
http://jsfiddle.net/kashyapa/hWXuF/embedded/result/
My requirement is  bind the dropdown list dynamically and based on change event bind another control .
Could you please suggest how to crate this type of templates in MVC  and If you have any samples could you please send?

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 13 Nov 2013, 02:39 PM
Hello Sirisha,

Basically you can render different template based on conditional logic like explained here:

http://docs.kendoui.com/getting-started/framework/templates/overview

Howeve I assume that for your case you want to create the DropDownList with JavaScript and bind it to different dataSource based on the data for that particular row. 

To actually achieve this I would suggest you to put a single input element in the template (with some class) and use the dataBound event of the Grid to initialize the DropDownList. To get a reference to the model while initializing the different DropDownList you can use the dataItem method of the Grid.

To get the idea please take a detail look at the following example:

http://jsbin.com/oletef/7/edit


It uses absolutely the same approach like the one that I explained above, however it uses a field which actually holds the whole collection (in your case you might just need an id to configure the remote transport of your DropDownList) to initialize the Chart.

I hope this gives you the idea and helps you achieve your goal.

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Discussions
Asked by
sirisha
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or