Autocomplete

Meal:

Autocomplete needs a controller or url to get data from, by default convention it will look for a controller with the same name as it + "Autocomplete"

  • action GetItems - gets the items for the autocomplete, it will receive a v parameter which represents the value of the textbox
AutocompleteDemo/Index.cshtml
Meal:@Html.Awe().AutocompleteFor(o => o.Meal).Placeholder("try Ma")
Awesome/Autocomplete/MealAutocompleteController.cs
public class MealAutocompleteController : Controller
{
public ActionResult GetItems(string v)// v is the entered text
{
v = (v ?? "").ToLower().Trim();

var items = Db.Meals.Where(o => o.Name.ToLower().Contains(v));

return Json(items.Take(10).Select(o => new KeyContent(o.Id, o.Name)));
}

Storing selected value key in a separate field using .PropId

Parent Category: you can (should) use hidden input instead

when the user selects a value from the autocomplete lists the PropId will be assigned the key of the selected value, but if the user will type something into the autocomlete after that the propId value will clear
AutocompleteDemo/Index.cshtml
Parent Category:
@(Html.Awe().AutocompleteFor(o => o.ParentCategory)
.Placeholder("try Le Fr")
.PropId(o => o.ParentCategoryId)
.Controller<CategoryAutocompleteController>())

@Html.TextBoxFor(o => o.ParentCategoryId) you can (should) use hidden input instead

Bound to parents

Parent Categories (MultiLookup):
  •  
and Parent Category:
Child Meal:

Numeric autocomplete

Prime number:

Using predefined parameters

Meal1 (parent = Fruits):
Meal2 (parent = Fruits, Legumes, Vegetables):