MVVM绑定后添加到Kendo MultiSelect

时间:2016-06-10 15:07:04

标签: javascript mvvm kendo-ui

我在我的一个页面上使用带有Kendo MultiSelect的MVVM模式。我遇到的问题是在MultiSelect DataSource中添加一个项目。

我拥有的JavaScript:

sizeof(long long)

在我的视图中选择标记:

CHAR_BIT

我已经尝试过执行标准sizeof,但是当我加载页面时,它还没有被添加到MultiSelect中。

我在这里错过了什么或做错了什么?

1 个答案:

答案 0 :(得分:1)

I do not see anything wrong in the above code. Could you ensure that API return the valid data?

https://plnkr.co/edit/zgu5ADxhlk5Tbq6B8XXM

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.common-material.min.css" />
    <link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.material.min.css" />
    <link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.default.mobile.min.css" />

    <script src="//kendo.cdn.telerik.com/2016.2.607/js/jquery.min.js"></script>
    <script src="//kendo.cdn.telerik.com/2016.2.607/js/kendo.all.min.js"></script>
</head>
<body>
<div id="buyer-profile-register">
  <h4>MultiSelect</h4>
  <select data-role="multiselect"
          data-placeholder="Select Type(s):"
          data-text-field="ProductName"
          data-value-field="ProductID"
          data-bind="source: productHandlingDataSource"
          ></select>
           
<script>
    var viewModel = kendo.observable({
        productHandlingDataSource: new kendo.data.DataSource({
            transport: {
                read: {
                    url: "//demos.telerik.com/kendo-ui/service/products",
                    dataType: "jsonp"
                }
            }
        })
    });
    kendo.bind($("#buyer-profile-register"), viewModel);
</script>
</div>


</body>
</html>