Kendo ui 基于剑道组合框的选择填充文本框

Kendo ui 基于剑道组合框的选择填充文本框,kendo-ui,asp.net-mvc-5,kendo-asp.net-mvc,kendo-combobox,Kendo Ui,Asp.net Mvc 5,Kendo Asp.net Mvc,Kendo Combobox,我需要根据MVC5应用程序中选择的组合框填充两个文本框控件。组合框是一个剑道MVC控件。需要分配给文本框控件的值位于绑定到组合框控件的集合中。谁能告诉我怎么办。这需要在javascript/jquery中处理还是在剑道组合框事件中处理。举个例子就好了 组合框 @Html.LabelFor(model => model.Name1, htmlAttributes: new { @class = "control-label col-md-4" })

我需要根据MVC5应用程序中选择的组合框填充两个文本框控件。组合框是一个剑道MVC控件。需要分配给文本框控件的值位于绑定到组合框控件的集合中。谁能告诉我怎么办。这需要在javascript/jquery中处理还是在剑道组合框事件中处理。举个例子就好了

组合框

        @Html.LabelFor(model => model.Name1, htmlAttributes: new { @class = "control-label col-md-4" })

        <div class="col-md-4">
            <div class="editor-field">
                @(Html.Kendo().ComboBoxFor(model => model.Name1)
                 
                    .HtmlAttributes(new { style = "width:300px" })
                    .DataTextField("Name1")
                    .DataValueField("CustomerMasterDataId")

                    .DataSource(dataSource => dataSource
                    .Read(read => read.Action("RequestHeader_CustomerData", "Request").Type(HttpVerbs.Post))
                    )
                )
            </div>
            @Html.ValidationMessageFor(model => model.CustomerNumber, "", new { @class = "text-danger" })
        </div>
 <div class="form-group">
                @Html.LabelFor(model => model.CustomerNumber, htmlAttributes: new { @class = "control-label col-md-4" })
                <div class="col-md-6">
                    <div class="editor-field">
                        @Html.EditorFor(model => model.CustomerNumber, new { htmlAttributes = new { @class = "form-control" } })

                    </div>
                    @Html.ValidationMessageFor(model => model.CustomerNumber, "", new { @class = "text-danger" })
                </div>
            </div>
            <div class="clearfix"></div>
            <div class="form-group">
                @Html.LabelFor(model => model.CustomerGroup, htmlAttributes: new { @class = "control-label col-md-4" })
                <div class="col-md-6">
                    <div class="editor-field">
                        @Html.EditorFor(model => model.CustomerGroup, new { htmlAttributes = new { @class = "form-control" } })

                    </div>
                    @Html.ValidationMessageFor(model => model.CustomerGroup, "", new { @class = "text-danger" })
                </div>
            </div>

是,处理更改事件:

@(Html.Kendo().ComboBoxFor(model => model.Name1)
      .HtmlAttributes(new { style = "width:300px" })
      .DataTextField("Name1")
      .DataValueField("CustomerMasterDataId")
      .DataSource(dataSource => dataSource
      .Events(e => e.Change(onComboChange))
      .Read(read => read.Action("RequestHeader_CustomerData", "Request").Type(HttpVerbs.Post))
                )
            )
现在在js中处理它:

@section scripts
{
    <script type="text/javascript">
        function onComboChange(e) {
            var dataItem = e.sender.dataItem();

            if (dataItem) {
                //set the value of text box (input)
                $("#CustomerNumber").val(dataItem.CustomerNumber);
                $("#CustomerGroup").val(dataItem.CustomerGroup);
            };
        };

    </script>
}
@节脚本
{
功能更改(e){
var dataItem=e.sender.dataItem();
如果(数据项){
//设置文本框的值(输入)
$(“#CustomerNumber”).val(dataItem.CustomerNumber);
$(“#CustomerGroup”).val(dataItem.CustomerGroup);
};
};
}
下面是一个js等价物:

@(Html.Kendo().ComboBoxFor(model => model.Name1)
      .HtmlAttributes(new { style = "width:300px" })
      .DataTextField("Name1")
      .DataValueField("CustomerMasterDataId")
      .DataSource(dataSource => dataSource
      .Events(e => e.Change(onComboChange))
      .Read(read => read.Action("RequestHeader_CustomerData", "Request").Type(HttpVerbs.Post))
                )
            )
@section scripts
{
    <script type="text/javascript">
        function onComboChange(e) {
            var dataItem = e.sender.dataItem();

            if (dataItem) {
                //set the value of text box (input)
                $("#CustomerNumber").val(dataItem.CustomerNumber);
                $("#CustomerGroup").val(dataItem.CustomerGroup);
            };
        };

    </script>
}