jQuery 使用 asp.net mvc 自动完成下拉菜单
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4711795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Autocomplete dropdown using asp.net mvc
提问by Suja Shyam
I have a dropdown in my CreateDocumentTemplate ciew <%=Html.DropDownList("Part", (SelectList)ViewData["Part"])%>
which is populated from database.
I want to this dropdown to be autocomplete. How can I acoomplish this?
我的 CreateDocumentTemplate ciew 中有一个下拉列表,<%=Html.DropDownList("Part", (SelectList)ViewData["Part"])%>
它是从数据库填充的。我想让这个下拉菜单自动完成。我怎样才能做到这一点?
回答by Gidon
Use for example jQueryUI (even comes packaged with MVC 3)
使用例如 jQueryUI(甚至与 MVC 3 一起打包)
回答by ilmatte
I wrote an Asp.Net WebControl wrapping the JQuery UI autocomplete widget.
我编写了一个包装 JQuery UI 自动完成小部件的 Asp.Net WebControl。
You can find it and the relative documentation at:
您可以在以下位置找到它和相关文档:
http://autocompletedotnet.codeplex.com/
http://autocompletedotnet.codeplex.com/
Hope it can help
希望它可以帮助
回答by Vladimir Georgiev
If you want a pure MVC component that you want to use directly in your Razor views - take a look at Shield UI's auto complete combobox.
如果您想要直接在 Razor 视图中使用的纯 MVC 组件,请查看 Shield UI 的自动完成组合框。
Sample usage is shown here:
示例用法如下所示:
@(Html.ShieldComboBox()
.Name("widget")
.HtmlAttribute("value", "Chart")
.DataSource(ds => ds.Remote(remote => remote.Read("/api/demo-stats"))
.Schema(schema => schema.Data("components"))
.FilterGroup(
Shield.Mvc.UI.DataSource.FilterCondition.And,
new object[] {
new Dictionary<string, object>() {
{"path", "name"},
{"filter", "contains"},
{"value", ""}
}
}))
.TextTemplate("{name}")
.ValueTemplate("{name}")
.AutoComplete(ac => ac.Enabled(true)))