代码之家  ›  专栏  ›  技术社区  ›  Tidis

在2个MVC小部件之间传递数据

  •  1
  • Tidis  · 技术社区  · 6 年前

    我已经用外部服务器的数据创建了一个小部件(组合框)。 我只想让我从组合框中选择的值显示在另一个小部件的标签中。

    组合框中小部件的来源:

    <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>
    

    有人能帮我吗?

    1 回复  |  直到 6 年前
        1
  •  0
  •   CMartins    6 年前

    您可以使用更改事件。将其放在数据源之后,并将类名添加到目标标签中

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

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