Question

Connected with the question below

Kendo-UI - Creating a Dynamic Form via JSON

I am creating dynamic forms. Normally when I create static forms, I write something like

$("#Field1").kendoDropDownList();

and the dropdown list is handled by kendo-ui css files. How can I add this in a dynamically added form field?

I tried to solve it in my template definition but didn't work

<script id="fieldsTemplate" type="text/x-kendo-template">
    <li>
        <label data-bind="attr: { for: name}, text: label"></label>
         # if (get("fieldtype") == "input") {#
        <input data-bind="value: value, attr: { type: type, name: name}" # if (get("required")) {# required #} # />
            #}else{#
                    <select id="name" data-bind="source: options, value: value, attr: { type: type, name: name}" data-text-field="option_value" data-value-field="option_id"  />
            #}#

            #$('#'+get("name")).kendoDropDownList();#
    </li>
</script>
Was it helpful?

Solution

I've done something similar using data attribute initialization. You put "data-role='dropdownlist'" in your select tag. Then after the call to load the template you use

kendo.init($('#YourContainerIdHere"));

Kendo's brief documentation is here: http://docs.telerik.com/kendo-ui/getting-started/data-attribute-initialization

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top