setting selected items in the controller by returning AweItems
instead of KeyContent[]
AjaxCheckboxListDemo.aspx
<% CategorySv.AjaxRadioList()
.Odropdown(o => o.AutoSelectFirst())
.DataFunc("aweUtils.getItems(categories)"); %>
<awe:Ocon runat="server" ID="CategorySv" />
<% MealsSv.AjaxCheckboxList()
.Parent(CategorySv.ClientID, "categories")
.Url(Page.Url().Action("GetMealsSetValue", "Data")); %>
<awe:Ocon runat="server" ID="MealsSv" />
Awesome/DataController.cs
public ActionResult GetMealsSetValue(int[] categories)
{
categories = categories ?? new int[] { };
var items = Db.Meals.Where(o => categories.Contains(o.Category.Id)).ToList();
object value = null;
if (items.Any())
{
value = new[] { items.Skip(1).First().Id };
}
return Json(new AweItems
{
Items = items.Select(o => new KeyContent(o.Id, o.Name)),
Value = value
});
}