我在我的MVC应用程序中实现了kendo组合框级联功能。我有一个名为Sales Organization的父组合框和两个分别称为Sales Office和Service Account manager的子组合框。级联功能仅适用于服务帐户管理器组合框。不确定是什么问题。我正在尝试使用从父组合框控件销售组织传递的国家/地区代码字段筛选销售办事处。子控件各自的控制器方法都被调用,但在第二个子控制器上,javascript函数GetFilterOption1()被触发。我不知道为什么第一个函数GetFilterOption()没有被触发。我检查了开发人员工具,没有看到任何错误。如果我发出$('#CountryCode')。val()的警报,我就会得到价值。函数本身没有触发
销售组织(父组合框)
<div class="form-group">
@Html.LabelFor(model => model.Company, htmlAttributes: new { @class = "control-label col-md-4" })
<div class="col-md-8">
<div class="editor-field">
@(Html.Kendo().ComboBoxFor(model => model.CountryCode)
.HtmlAttributes(new { style = "width:100%" })
.DataTextField("CompanyCodeCompany")
.DataValueField("CountryCode")
.Filter("contains")
.MinLength(3)
.DataSource(dataSource => dataSource
.Read(read => read.Action("RequestHeader_SalesOrganisation", "Request").Type(HttpVerbs.Post))
.ServerFiltering(true)
)
)
</div>
@Html.ValidationMessageFor(model => model.Company, "", new { @class = "text-danger" })
</div>
</div>
销售办公室(First Child组合框)
<div class="form-group">
@Html.LabelFor(model => model.SalesOffice, htmlAttributes: new { @class = "control-label col-md-4" })
<div class="col-md-8">
<div class="editor-field">
@(Html.Kendo().ComboBoxFor(model => model.SalesOfficeID)
.HtmlAttributes(new { style = "width:100%" })
.DataTextField("SalesOffice")
.DataValueField("SalesOfficeID")
.AutoBind(false)
.Value("")
.DataSource(dataSource => dataSource
.Read(read =>
{
read.Action("RequestHeader_SalesOffice", "Request")
.Type(HttpVerbs.Post)
.Data("GetFilterOption");
}).ServerFiltering(true)
).CascadeFrom("CountryCode").Filter("contains")
)
</div>
@Html.ValidationMessageFor(model => model.SalesOffice, "", new { @class = "text-danger" })
</div>
</div>
服务客户经理(第二个儿童组合)
<div class="form-group">
@Html.LabelFor(model => model.NameOfResponsiblePerson, htmlAttributes: new { @class = "control-label col-md-5" })
<div class="col-md-7 col-md-pull-1">
@(Html.Kendo().ComboBoxFor(model => model.PersonResponsibleMasterDataId)
// .Name("Sam")
.HtmlAttributes(new { style = "width:100%" })
.DataTextField("NameOfResponsiblePerson")
.DataValueField("PersonResponsibleMasterDataId")
.DataSource(dataSource => dataSource
.Read(read =>
{
read.Action("RequestHeader_PersonResponsibleMasterData", "Request")
.Type(HttpVerbs.Post)
.Data("GetFilterOption1");
}).ServerFiltering(true)
).CascadeFrom("CountryCode").Filter("contains")
)
</div>
</div>
Javascript
function GetFilterOption() {
return { id: $('#CountryCode').val() }
}
function GetFilterOption1() {
return { id: $('[name = "CountryCode"]').data("kendoComboBox").text().split('-')[0] }
}