MultiLookup
It can be declared using the MultiLookup or MultiLookupFor helper like this:
@Html.Awe().MultiLookupFor(o => o.Meal)
@Html.Awe().MultiLookup("Category")
It requires a controller to get it's data from, this controller must have 3 actions GetItems, Selected, and Search, example:
public class CategoriesMultiLookupController : Controller
{
public ActionResult GetItems(int[] v)
{
return Json(Db.Categories.Where(o => v != null && v.Contains(o.Id))
.Select(f => new KeyContent(f.Id, f.Name)));
}
public ActionResult Search(string search, int[] selected)
{
return Json(new AjaxListResult
{
Items = Db.Categories.Where(o => o.Name.Contains(search) && (selected == null || !selected.Contains(o.Id)))
.Select(o => new KeyContent(o.Id, o.Name))
});
}
public ActionResult Selected(int[] selected)
{
return Json(
new AjaxListResult
{
Items = Db.Categories.Where(o => selected != null && selected.Contains(o.Id))
.Select(o => new KeyContent(o.Id, o.Name))
});
}
}
- GetItems is used to display the selected values
- Search is used when the user opens the MultiLookup's popup and searches for items
- Selected is used to show the list of selected items int the popup
Pagination, Custom Item Layout and Table Layout
It has all these features just like the AjaxList (note that Search and Selected actions return Json(AjaxListResult))