AutoComplete
AutoComplete
Complex Type
Features
Sample
Type in a system color name. Try to type in "red".
Description
This sample shows how to bind to a list of complex type using "DisplayMemberPath" and "SelectedValuePath".
Source
ComplexTypeController.cs
using System; using System.Linq; using Microsoft.AspNetCore.Mvc; using MvcExplorer.Models; namespace MvcExplorer.Controllers { public partial class AutoCompleteController : Controller { public ActionResult ComplexType() { var list = GetSystemColors(); return View(list); } private static NamedColor[] GetSystemColors() { return Enum.GetValues(typeof(ConsoleColor)) .Cast<ConsoleColor>() .Select(c => new NamedColor { Name = c.ToString(), Value = (int)c }) .ToArray(); } } }
ComplexType.cshtml
@model IEnumerable<NamedColor> <div> <label>@Html.Raw(AutoCompleteRes.ComplexType_Text1)</label> <p>@Html.Raw(AutoCompleteRes.ComplexType_Text0)</p> <c1-auto-complete display-member-path="Name" selected-value-path="Value"> <c1-items-source source-collection="@Model"> </c1-items-source> </c1-auto-complete> </div> @section Description{ @Html.Raw(AutoCompleteRes.ComplexType_Text2) }
Documentation