<% ParentCategory.AjaxRadioList().Url(Page.Url().Action("GetCategories", "Data")); %><awe:Ocon runat="server" ID="ParentCategory" /><% ChildMeal.AjaxRadioList().Url(Page.Url().Action("GetMeals", "Data")) .Parent(ParentCategory.ClientID, "categories"); %><awe:Ocon runat="server" ID="ChildMeal" />
public ActionResult GetCategories(){ return this.AweJson(Db.Categories.Select(o => new KeyContent(o.Id, o.Name)));}public ActionResult GetMeals(int[] categories){ categories = categories ?? new int[] { }; var items = Db.Meals.Where(o => categories.Contains(o.Category.Id)) .Select(o => new KeyContent(o.Id, o.Name)); return this.AweJson(items);}
<% Categories.AjaxCheckboxList().Url(Page.Url().Action("GetCategories", "Data")); %><awe:Ocon runat="server" ID="Categories" /><% Category2.AjaxRadioList().Url(Page.Url().Action("GetCategories", "Data")); %><awe:Ocon runat="server" ID="Category2" /><% ChildOfManyMeal.AjaxRadioList().Url(Page.Url().Action("GetMeals", "Data")) .Parent(Categories.ClientID, "categories").Parent(Category2.ClientID, "categories"); %><awe:Ocon runat="server" ID="ChildOfManyMeal" />
.Url(str)
.DataFunc(jsFunc)
<script> var meals = <%=DemoUtils.Encode(Db.Meals.Select(o => new KeyContent(o.Id, o.Name))) %>; var categories = <%=DemoUtils.Encode(Db.Categories.Select(o => new KeyContent(o.Id, o.Name))) %>; function setCategs() { return categories; }</script><% CatClient1.AjaxRadioList().DataFunc("setCategs"); %><awe:Ocon runat="server" ID="CatClient1" /><%--instead of setCategs we can also use aweUtils.getItems(categories)--%>
<% CategoryOchk.RadioButtonList(new RadioButtonListOpt { Value = Db.Categories[0].Id, Url = Page.Url().Action("GetCategories", "Data") }); %><awe:Ocon runat="server" ID="CategoryOchk" /><%--can also use .Url(url)--%>
<% CategoriesButtonGroup.ButtonGroup(new ButtonGroupOpt { Url = Page.Url().Action("GetCategories", "Data") }); %><awe:Ocon runat="server" ID="CategoriesButtonGroup" />
<% AllMealsDD.DropdownList(new DropdownListOpt { Url = Page.Url().Action("GetMealsImg", "Data") }); %><awe:Ocon runat="server" ID="AllMealsDD" />
<% CatDD.DropdownList(new DropdownListOpt { Url = Page.Url().Action("GetCategories", "Data") });%><awe:Ocon runat="server" ID="CatDD" /><% MealsDD.DropdownList(new DropdownListOpt { AutoSelectFirst = true, Url = Page.Url().Action("GetMeals", "Data") }.Parent(CatDD.ClientID, "categories")); %><awe:Ocon runat="server" ID="MealsDD" />
<% AllMealsCombo.Combobox(new ComboboxOpt { Value = "combo value", Url = Page.Url().Action("GetMealsImg", "Data") }); %><awe:Ocon runat="server" ID="AllMealsCombo" />
<% ColorPicker1.AjaxRadioList().ColorDropdown(o => o.AutoSelectFirst()); %><awe:Ocon runat="server" ID="ColorPicker1" />
<% CustomItemOdd.DropdownList(new DropdownListOpt { Value = Db.Meals[1].Id, Url = Page.Url().Action("GetMealsImg", "Data") }.ImgItem()); %><awe:Ocon runat="server" ID="CustomItemOdd" />
public ActionResult GetMealsImg(){ var url = Url.Content(DemoUtils.MealsUrl); var items = Db.Meals .Select(o => new MealDisplay(o.Id, o.Name, url + o.ImageName)); return this.AweJson(items);}
<% RemoteSearchDD.DropdownList(new DropdownListOpt { Value = 225, Url = Page.Url().Action("GetMealsInit", "Data"), SearchFunc = new SearchFuncOpt { Name = "aweUtils.osearch", Url = Page.Url().Action("SearchMeals", "Data"), Key = "m1" } }); %><awe:Ocon runat="server" ID="RemoteSearchDD" /><% RemoteSearchCombobox.Combobox(new ComboboxOpt { Value = 225, Url = Page.Url().Action("GetMealsInit", "Data"), SearchFunc = new SearchFuncOpt { Name = "aweUtils.osearch", Url = Page.Url().Action("SearchMeals", "Data"), Key = "m1" } }); %><awe:Ocon runat="server" ID="RemoteSearchCombobox" /><span class="hint">try 'o'</span>
public ActionResult GetMealsInit(int? v){ var items = Db.Meals.Take(3).ToList(); var selected = Db.Meals.SingleOrDefault(o => o.Id == v); if (selected != null && !items.Contains(selected)) { items.Add(selected); } return this.AweJson(items.Select(o => new KeyContent(o.Id, o.Name)));}public ActionResult SearchMeals(string term = ""){ var items = Db.Meals .Where(o => o.Name.IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0) .Take(10) .Select(o => new KeyContent(o.Id, o.Name)); return this.AweJson(items);}
<h2>Set value from get items call</h2><% CategorySv.DropdownList(new DropdownListOpt { Url = Page.Url().Action("GetCategories", "Data"), AutoSelectFirst = true }); %><awe:Ocon runat="server" ID="CategorySv" /><% MealsSv.DropdownList(new DropdownListOpt { Url = Page.Url().Action("GetMealsSetValue2", "Data") }.Parent(CategorySv.ClientID, "categories")); %><awe:Ocon runat="server" ID="MealsSv" /><br /><br /><% OrgsSv.DropdownList(new DropdownListOpt { Url = Page.Url().Action("GetOrgSetValue", "Data"), }); %><awe:Ocon runat="server" ID="OrgsSv" />
public ActionResult GetMealsSetValue2(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 = items.Skip(1).First().Id; } return this.AweJson(new AweItems { Items = items.Select(o => new KeyContent(o.Id, o.Name)), Value = value });}public ActionResult GetOrgSetValue(){ var items = Db.Organisations.ToList(); object value = null; if (items.Any()) { value = items.Skip(2).First().Id; } return this.AweJson(new AweItems { Items = items.Select(o => new KeyContent(o.Id, o.Name)), Value = value });}