开发者

Autocomplete dropdown using asp.net mvc

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?


Use for example jQueryUI (even comes packaged with MVC 3)

http://jqueryui.com/demos/autocomplete/#combobox


I wrote an Asp.Net WebControl wrapping the JQuery UI autocomplete widget.

You can find it and the relative documentation at:

http://autocompletedotnet.codeplex.com/

Hope it can help


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.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜