一起使用自动完成和下拉列表

时间:2014-02-18 16:21:03

标签: jquery asp.net-mvc autocomplete kendo-ui

我在Kendo UI中使用JSON dataSource使用ASP.NET MVC-5应用程序自动完成...工作正常,现在我想要自动完成的下拉菜单,所以当用户输入时值,程序开始过滤数据,但用户也可以下拉并从列表中选择.....

控制器

 public ActionResult GetAllFeeScheme_JSON()
    {        
        var allFeeScheme = FeeScheme_UOF.GetAllFeeScheme().ToList();

        return Json(allFeeScheme, JsonRequestBehavior.AllowGet);
    }

Partial_View

<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>

非常感谢

1 个答案:

答案 0 :(得分:2)

解决方案如下

 $("#_FeeScheme_Input").kendoComboBox({
        minLength: 1,
        filter: 'contains',
        dataTextField: "FeeSchemeDescription",
        dataValueField: "FeeSchemeID",
        dataSource: {
            type: "json",
            serverFiltering: false,
            transport: {
                read: "/Qualification/GetAllFeeScheme_JSON"
            },
        }
    });