Kendo ui 如何在剑道UI中将动态输入字段设置为数字文本框?

Kendo ui 如何在剑道UI中将动态输入字段设置为数字文本框?,kendo-ui,telerik,kendo-mvvm,kendonumerictextbox,Kendo Ui,Telerik,Kendo Mvvm,Kendonumerictextbox,这是我的情况 我用这个做了一个动态表单 在这里你可以看到它的文章演示使用剑道模板 那我还有什么选择呢?? 非常感谢您必须将数据角色属性设置为输入元素,才能将元素转换为剑道控制/元素。请尝试使用下面的代码段 <body> <div id="example"> <!-- container UL to host input fields --> <ul data-template="fieldsTemplate" da

这是我的情况

我用这个做了一个动态表单

在这里你可以看到它的文章演示使用剑道模板

那我还有什么选择呢??
非常感谢

您必须将数据角色属性设置为输入元素,才能将元素转换为剑道控制/元素。请尝试使用下面的代码段

<body>
    <div id="example">
        <!-- container UL to host input fields -->
        <ul data-template="fieldsTemplate" data-bind="source: fields"></ul>
    </div>


    <!-- Kendo Template binds properties from model to input fields -->
    <script id="fieldsTemplate" type="text/x-kendo-template">
        <li>
            <label data-bind="attr: { for: name}, text: label"></label>
            <input name=#= name #  class=#= css # # if (get("required")) {# required #} # 
              # if (type == 'number') {# data-role="numerictextbox" #}else{# type=#=type#  #}#  />
        </li> 
    </script>

    <script type="text/javascript">
        // retrieve the model from an API call
        var model = {
            "fields": [{
                "css": "cssClass1",
                "label": "Field 1",
                "name": "Field1",
                "required": false,
                "type": "text"
            },
            {
                "css": "cssClass2",
                "label": "Field 2",
                "name": "Field2",
                "required": true,
                "type": "number"
            },
            {
                "css": "cssClass2",
                "label": "Checkbox Field",
                "name": "CheckField",
                "required": false,
                "type": "checkbox"
            },
            {
                "css": "cssClass2",
                "label": "Email Address",
                "name": "Email",
                "required": true,
                "type": "email"
            },
            {
                "css": "cssClass2",
                "label": "Password",
                "name": "Password",
                "required": true,
                "type": "password"
            }
            ]
        };
        // convert the JSON to observable object
        var viewModel = kendo.observable(model);
        // bind the model to the container
        kendo.bind($("#example"), viewModel);

    </script>
</body>

如果有任何问题,请告诉我。

我已经试过了。但这对我不起作用。工作很好。但不显示剑道数字文本框。我已经在JSFIDLE中创建了完整的演示,并在上面的回答中添加了它的链接。文件2有剑道数字文本框。嘿,兄弟。。在你的帮助下我成功了。这是一个向输入字段添加类的例子。谢谢你的帮助,兄弟。对于JSFiddle也是如此
      $("#mytextboxid").kendoNumericTextBox();​
<body>
    <div id="example">
        <!-- container UL to host input fields -->
        <ul data-template="fieldsTemplate" data-bind="source: fields"></ul>
    </div>


    <!-- Kendo Template binds properties from model to input fields -->
    <script id="fieldsTemplate" type="text/x-kendo-template">
        <li>
            <label data-bind="attr: { for: name}, text: label"></label>
            <input name=#= name #  class=#= css # # if (get("required")) {# required #} # 
              # if (type == 'number') {# data-role="numerictextbox" #}else{# type=#=type#  #}#  />
        </li> 
    </script>

    <script type="text/javascript">
        // retrieve the model from an API call
        var model = {
            "fields": [{
                "css": "cssClass1",
                "label": "Field 1",
                "name": "Field1",
                "required": false,
                "type": "text"
            },
            {
                "css": "cssClass2",
                "label": "Field 2",
                "name": "Field2",
                "required": true,
                "type": "number"
            },
            {
                "css": "cssClass2",
                "label": "Checkbox Field",
                "name": "CheckField",
                "required": false,
                "type": "checkbox"
            },
            {
                "css": "cssClass2",
                "label": "Email Address",
                "name": "Email",
                "required": true,
                "type": "email"
            },
            {
                "css": "cssClass2",
                "label": "Password",
                "name": "Password",
                "required": true,
                "type": "password"
            }
            ]
        };
        // convert the JSON to observable object
        var viewModel = kendo.observable(model);
        // bind the model to the container
        kendo.bind($("#example"), viewModel);

    </script>
</body>