【问题标题】:Kendo UI and templates : bind value with an observable model and the source with and external datasourceKendo UI 和模板:将值与可观察模型和源与外部数据源绑定
【发布时间】:2013-12-02 08:47:46
【问题描述】:

我在 Kendo UI 中使用 MVVM 和模板。 我希望我的模板包含一个下拉列表,其中包含我的模型的绑定值和带有外部数据源

我的可观察对象看起来像这样:

data : {
    comments : "any comments here...",
    nested_object_array : [
        {id:0, name:"name_0", nested_value:"20"},
        {id:1, name:"name_1", nested_value:"21"},
        //...
    ]
}

我希望我的模板看起来像这样:

<script id="global-template" type="text/x-kendo-template">
    <span Data-bind="text: comments"></span>    
</script>

<script id="sub-template" type="text/x-kendo-template">
    <input data-role="dropdown" data-source="--here an external source--" data-bind="value: nested_value" />
</script>

有可能吗?如果是,该怎么做?

【问题讨论】:

  • 嗨,鲍比,非常感谢您的回答。我暂时没有尝试。我会尽快给你反馈。

标签: templates mvvm kendo-ui


【解决方案1】:

下面的例子似乎很清楚地涵盖了它 - here

模板:

<script id="sub-template" type="text/x-kendo-template">
      <input data-role="dropdownlist"
                       data-auto-bind="false"
                       data-text-field="ProductName"
                       data-value-field="ProductID"
                       data-bind="value: selectedProduct,
                                  source: yourexternaldatasource,
                                  visible: isVisible,
                                  enabled: isEnabled"
                       style="width: 180px"
                />
</script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-07
    • 1970-01-01
    • 1970-01-01
    • 2012-12-03
    • 1970-01-01
    • 2014-01-15
    • 2018-05-13
    • 2018-11-19
    相关资源
    最近更新 更多