Quick overview:

 
  •  
 
 

Grid, search using parent binding

Grid, search using Parent binding.
Default.aspx
<div class="bar">
<% Txtperson.TextBox().Placeholder("search for person ...").CssClass("searchtxt"); %>
<awe:Ocon runat="server" ID="Txtperson" />
<% Txtfood.TextBox().Placeholder("search for food ...").CssClass("searchtxt"); %>
<awe:Ocon runat="server" ID="Txtfood" />
<% OCountry.AjaxRadioList().Url(Page.Url().Action("GetCountries", "Data")).Odropdown().HtmlAttributes(new { style = "min-width:15em;" }); %>
<awe:Ocon runat="server" ID="OCountry" />
</div>

<% Grid1.Grid()
.Reorderable()
.Mod(o => o.PageInfo().PageSize().AutoMiniPager().ColumnsSelector())
.Columns(
new Column { Bind = "Id", Width = 75, Groupable = false, Resizable = false },
new Column { Bind = "Person" }.Mod(o => o.Nohide()),
new Column { Bind = "Food" },
new Column { Bind = "Location" },
new Column { Bind = "Date", Width = 120 }.Mod(o => o.Autohide()),
new Column { Bind = "Country.Name", ClientFormat = ".CountryName", Header = "Country" }.Mod(o => o.Autohide()),
new Column { Bind = "Chef.FirstName,Chef.LastName", ClientFormat = ".ChefName", Header = "Chef" }.Mod(o => o.Autohide()))
.Url(Page.Url().Action("GetItems", "LunchGrid"))
.Persistence(Persistence.Session) // save collapsed groups and nodes when switching between grid pages
.ColumnsPersistence(Persistence.Session) // save columns (width, visibility, etc..) for browser session lifetime
.Resizable()
.Height(350)
.Parent(Txtperson.ClientID, "person")
.Parent(Txtfood.ClientID, "food")
.Parent(OCountry.ClientID, "country"); %>
<awe:Ocon runat="server" ID="Grid1" />
Awesome/Grid/LunchGridController.cs
public class LunchGridController : Controller
{
public ActionResult GetItems(GridParams g, string person, string food, int? country)
{
food = (food ?? "").ToLower();
person = (person ?? "").ToLower();

var list = Db.Lunches
.Where(o => o.Food.ToLower().Contains(food) && o.Person.ToLower().Contains(person))
.AsQueryable();

if (country.HasValue) list = list.Where(o => o.Country.Id == country);

return Json(new GridModelBuilder<Lunch>(list, g)
{
KeyProp = o => o.Id,// needed for Entity Framework | nesting | tree | api
Map = o => new
{
o.Id,
o.Person,
o.Food,
o.Location,
o.Price,
Date = o.Date.ToShortDateString(),
CountryName = o.Country.Name,
ChefName = o.Chef.FirstName + " " + o.Chef.LastName
}
}.Build());
}
}
Default.aspx

<button type="button" class="awe-btn" onclick="awem.notif('Hi,</br> how are you ! ', 5000)">Show Notification</button>
<button type="button" class="awe-btn redbtn" onclick="awem.notif('<h5>Oops !</h5> error example ', 0, 'o-err')">Show Error</button>
<button type="button" class="awe-btn" onclick="awe.flash($(this).parent())">Flash</button>
<button type="button" class="awe-btn" onclick="awe.flash(awem.notif('Hi,</br> how are you ! ', 5000))">Flash Notify</button>





Comments