【问题标题】:Passing data between 2 MVC widgets在 2 个 MVC 小部件之间传递数据
【发布时间】:2018-03-15 14:02:39
【问题描述】:

我已经使用来自外部服务器的数据创建了一个小部件(组合框)。 我只想从该组合框中选择的值从另一个小部件的标签中看到。

来自组合框的小部件来源:

<div id="exampleCombo">
        <div class="demo-section k-content">
            <h4>Facility</h4>
            <input id="fac" style="width: 30%;" />
        </div>
    <script>
        $(document).ready(function (user) {
            $("#fac").kendoComboBox({
                dataTextField: "client",
                dataValueField: "client",
                order: "ascending",
                height: 400,
                dataSource: {
                    // type: "odata",
                    type: "json",
                    transport: {

                        read: "/mvc/controllers/UserfacilitiesCombo/get/" + user
                    },
                    group: { field: "facility" }
                },
            });

        });

带有标签的小部件的来源:

 <div id="exampleLabel">
        <div class="demo-section k-content">
            <ul class="forms">
                <li>
                    <label>FacilityName</label>
                    <input id="FacPass"  name="FacPass" value="Test" class="k-textbox" style="width: 100%;" />
                </li>
            </ul>
        </div>

有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: model-view-controller kendo-ui telerik


    【解决方案1】:

    您可以使用更改事件。把它放在你的数据源之后,并在你的目标标签中添加一个类名

    change: function(e) {
        var value = this.value();
        $('.yourLabelClass').html(value);
      }
    

    这里是有关可用活动的更多信息 https://docs.telerik.com/kendo-ui/api/javascript/ui/combobox/events/change

    【讨论】:

      猜你喜欢
      • 2019-04-22
      • 1970-01-01
      • 1970-01-01
      • 2018-02-22
      • 1970-01-01
      • 2017-08-12
      • 2020-10-07
      • 2013-10-12
      • 2017-12-27
      相关资源
      最近更新 更多