我在Kendo UI中使用JSON dataSource使用ASP.NET MVC-5应用程序自动完成...工作正常,现在我想要自动完成的下拉菜单,所以当用户输入时值,程序开始过滤数据,但用户也可以下拉并从列表中选择.....
public ActionResult GetAllFeeScheme_JSON()
{
var allFeeScheme = FeeScheme_UOF.GetAllFeeScheme().ToList();
return Json(allFeeScheme, JsonRequestBehavior.AllowGet);
}
<div class="form-group">
@Html.LabelFor(model => model._FeeScheme.FeeSchemeDescription, new { @class = "control-label col-md-3" })
<div class="col-md-6">
@Html.TextBoxFor(model => model._FeeScheme.FeeSchemeDescription, new { id = "_FeeScheme_Input" })
@Html.ValidationMessageFor(model => model._FeeScheme.FeeSchemeDescription)
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#_FeeScheme_Input").kendoAutoComplete({
minLength: 2,
filter: 'contains',
dataTextField: "FeeSchemeDescription",
dataSource: {
type: "json",
serverFiltering: false,
transport: {
read: "/Qualification/GetAllFeeScheme_JSON"
},
}
});
});
</script>
非常感谢
答案 0 :(得分:2)
解决方案如下
$("#_FeeScheme_Input").kendoComboBox({
minLength: 1,
filter: 'contains',
dataTextField: "FeeSchemeDescription",
dataValueField: "FeeSchemeID",
dataSource: {
type: "json",
serverFiltering: false,
transport: {
read: "/Qualification/GetAllFeeScheme_JSON"
},
}
});