Grid basic features and search using Parent binding.
Some columns have autohide mod, you can resize the browser window to see the columns hide and show depending on window width.
<div class="bar">
<% Txtperson.TextBox().Placeholder("search for person ...").CssClass("searchtxt"); %>
<awe:ocon runat="server" id="Txtperson" />
<% TxtDish.TextBox().Placeholder("search for Dish ...").CssClass("searchtxt"); %>
<awe:ocon runat="server" id="TxtDish" />
<%--<% OCountry.AjaxRadioList().Url(Page.Url().Action("GetCountries", "Data")).Odropdown().HtmlAttributes(new { style = "min-width:15em;" }); %>--%>
<% OCountry.DropdownList(new DropdownListOpt {
Url = Page.Url().Action("GetCountries", "Data")
}); %>
<awe:ocon runat="server" id="OCountry" />
</div>
<% Grid1.Grid<Lunch>()
.Main()
.Url(Page.Url().Action("GetItems", "LunchGrid"))
.Columns(b =>
{
b.Add(o => o.Id).Width(75);
b.Add(o => o.Person);
b.Add(o => o.Dish.Name, new Column { ClientFormatFunc = "site.imgDish", MinWidth = 200 });
b.Add(o => o.Country.Name);
b.Add(o => o.Date).Grow(.1);
b.Add(o => o.Location);
b.Add(o => new {o.Chef.FirstName, o.Chef.LastName});
})
.Persistence(Persistence.Session) // save collapsed groups and nodes when switching between grid pages.
.Height(350)
.Parent(Txtperson.ClientID, "person")
.Parent(TxtDish.ClientID, "Dish")
.Parent(OCountry.ClientID, "country"); %>
<awe:ocon runat="server" id="Grid1" />
<script>
var root = '<%=ResolveUrl("~/Content/Pictures/Dish/") %>';
function imgDish(itm) {
return '<img src="' + root + itm.DishPic + '" class="Dish" />' + itm.Dish;
}
</script>
Awesome/Grid/LunchGridController.cs
using System;
using System.Linq;
using AwesomeWebFormsDemo.Data;
using AwesomeWebFormsDemo.Models;
using AwesomeWebFormsDemo.Utils.Awesome;
using System.Web.Mvc;
using Omu.AwesomeWebForms;
namespace AwesomeWebFormsDemo.Controllers.Awesome.Grid
{
public class LunchGridController : Controller
{
public ActionResult GetItems(GridParams g, int? country, string person, string dish)
{
var query = Db.Lunches.AsQueryable();
var gmb = new GridModelBuilder<Lunch>(query.AsQueryable(), g);
gmb.KeyProp = o => o.Id;
// for when using parent controls filters
gmb.FilterContainsStr(o => o.Person, person)
.FilterContainsStr(o => o.Dish.Name, dish)
.FilterEq(o => o.Country.Id, country);
// props used in site.imgDish js function
gmb.Prop(o => o.Dish.Pic, "DishPic");
gmb.Prop(o => o.Dish.Name, "DishName");
// used by some demos (GridFrozenColumns)`
gmb.Prop(o => o.Organic, render: o => o ? "Yes" : "No");
return this.AweJson(gmb.Build());
}
}
}