我有以下三个 KendoUI 下拉列表框
@(Html.Kendo().DropDownList()
.HtmlAttributes(new { style = "width:120px;height:20px;font-size:12px;" })
.OptionLabel("Make (any)")
.Name("Make")
.DataTextField("Name")
.DataValueField("Id")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("UpdateFilters", "Home");
})
.ServerFiltering(true);
})
.Events(e => e.Change("UpdateFilterParameters"))
.SelectedIndex(0) //Select first item.
)
@(Html.Kendo().DropDownList()
.Name("Model")
.HtmlAttributes(new { style = "width:120px;height:20px;font-size:12px;'" })
.OptionLabel("Model (any)")
.DataTextField("Name")
.DataValueField("Id")
.DataSource(source => {
source.Read(read =>
{
read.Action("UpdateFilters", "Home");
})
.ServerFiltering(true);
})
.Enable(true)
.AutoBind(true)
.Events(e => e.Change("UpdateFilterParameters"))
)
@(Html.Kendo().DropDownList()
.Name("Fuel")
.HtmlAttributes(new { style = "width:120px;height:20px;font-size:12px;" })
.OptionLabel("Fuel type (any)")
.DataTextField("Name")
.DataValueField("Id")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("UpdateFilters", "Home");
})
.ServerFiltering(true);
})
.Enable(true)
.AutoBind(true)
.Events(e => e.Change("UpdateFilterParameters"))
)
这是我的 MVC 控制器
public JsonResult UpdateFilters(string FilterInfo)
{
FilterParameter oFilterInfo = new FilterParameter();
// Json object for filtering
// {'Procedure':'GetMakes','Id':[1,2,3]}
try
{
oFilterInfo = JsonConvert.DeserializeObject<FilterParameter>(FilterInfo);
return Json(UpdateFilterParameter.GetUpdatedFilters(oFilterInfo), JsonRequestBehavior.AllowGet);
}
catch
{
return new JsonResult();
}
}
这是我保存 Json 数据的课程
public class FilterParameter
{
public string Procedure { get; set; }
public int?[] Id;
public FilterParameter()
{
}
}
我遇到的问题是在调用 JavaScript 函数 UpdateFilterParameters 时,我只获取任一列表框的值,但不是全部。这是功能;
function UpdateFilterParameters() {
var iMake = $("#Make").val();
var iModel = $("#Model").val();
var iFuel = $("#Fuel").val();
$('#Make').data("kendoDropDownList").dataSource.read(
{ FilterInfo: "{'Procedure':'GetMakes','Id':[" + iMake + "," + iModel + "," + iFuel + "]}" });
$('#Model').data("kendoDropDownList").dataSource.read(
{ FilterInfo: "{'Procedure':'GetModels','Id':[" + iMake + "," + iModel + "," + iFuel + "]}" });
$('#Fuel').data("kendoDropDownList").dataSource.read(
{ FilterInfo: "{'Procedure':'GetFuelTypes','Id':[" + iMake + "," + iModel + "," + iFuel + "]}" });
};
任何想法为什么会发生这种情况?