ASP.net Core Awesome Controls overview
Grid bound to parent controls for filtering
Grid bound using the parent extension to two textboxes (txtPerson, txtDish) and a dropdown list (selCountry) for filtering.
Fetches data for the current page from the controller.
Has reordering, resizing, and session-based persistence, and auto-hiding based on available width for two columns (Date and Location).
Fetches data for the current page from the controller.
Has reordering, resizing, and session-based persistence, and auto-hiding based on available width for two columns (Date and Location).
Home/Index.cshtml
<h2>Grid bound to parent controls for filtering</h2>
<div class="bar">
@Html.Awe().TextBox(new TextBoxOpt { Name = "txtPerson", Placeholder = "search for person ...", CssClass = "searchtxt", ClearBtn = true })
@Html.Awe().TextBox(new TextBoxOpt { Name = "txtDish", Placeholder = "search for dish ...", CssClass = "searchtxt", ClearBtn = true })
@(Html.Awe().DropdownList(new DropdownListOpt
{
Name = "selCountry",
Url = Url.Action("GetCountries", "Data"),
ClearBtn = true
}))
</div>
@(Html.Awex().Grid<Lunch>("mainGrid1")
.Main()
.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});
})
.Url(Url.Action("GetItems", "LunchGrid"))
.Height(330)
.Persistence(Persistence.Session)
.Parent("txtPerson", "person")
.Parent("txtDish", "dish")
.Parent("selCountry", "country"))
Awesome/Grid/LunchGridController.cs
public IActionResult 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());
}
See also:
Side Menu
Deferred Load
TreeGrid, Popup CRUD
TreeGrid Inline Editing
Master Detail Crud Demo
Wizard Demo
Comments