Grid control basic features

The Awesome Grid control for ASP.net Core and MVC is used to display data, by default using a table, but that can be changed. Documentation

It can get the data from the server by specifying the url Url(urlstr) or from a js function DataFunc(jsfunc) (the javascript function could also do an ajax request and return the promise).
The Grid (like most awesome controls) can be bound to other controls using the Parent extension (used for filtering). It can also be filtered using the api.
Mods are used to add additional features to the grid like: inline editing, automatic columns hiding and via dropdown, adaptive pager (based on window width), and more.

Features:

Other grid crud demos: Grid Crud (Popup), Grid in nest editing, Master Detail Crud Demo
GridDemo/Index.cshtml
<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>("grid1")
.Main()
.Url(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.Price).Width(100);
b.Add(o => o.Meals.Select(m => m.Name)).MinWidth(230);
b.Add(o => o.Location);
b.Add(o => new { o.Chef.FirstName, o.Chef.LastName }).AutoHide();
})
.Persistence(Persistence.Session)
.Height(350)
.Parent("txtPerson", "person")
.Parent("txtDish", "dish")
.Parent("selCountry", "country"))
Awesome/Grid/LunchGridController.cs
public class LunchGridController : Controller
{
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:

Awesome Grid Video Tutorial
Grid Client Data Demo
Grid Mailbox Demo



Comments