我在我的应用程序中使用了 Kendo-Drop Down 框,我想在此下拉框中添加可搜索功能,但它不起作用..所以请任何伙伴帮助我..
@(Html.Kendo().DropDownList()
.Name("PCODE")
.OptionLabel("--Select--")
.HtmlAttributes(new { style = "width:100%;" })
.DataTextField("PCODE")
.DataValueField("EmpId")
.HtmlAttributes(new { @class = "kendo-Drop-PCode" })
.Filter("contain")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetEmployeeList", "Common");
})
.ServerFiltering(true);
}
)
)
最佳答案
我收集到的一些东西:
1) .Filter 需要说 .Filter("contains") 而不是 Filter("contain")
2) 如果您打算进行服务器过滤,您需要将输入文本的值发送回服务器,然后将其作为请求的一部分进行处理,例如
source.Read(read =>
{
read.Action("GetEmployeeList", "Common").Data("GetFilterValue")
})
function GetFilterValue()
{
return {filterValue: $("#PCODE").data("kendoDropDownList").filterInput.val() };
}
然后在您的 Controller 中修改签名以接受输入值:
public JsonResult GetEmployeeList(string filterValue = "")
{
do something in here....
}
关于javascript - Kendo-下拉搜索功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27598661/