Result
OrderID | ContactName | City | CompanyName | ShipRegion | Quantity |
---|
| Paul Henriot | Reims | Federal Shipping | | 12 |
| Karin Josephs | Münster | Speedy Express | | 9 |
| Mario Pontes | Rio de Janeiro | United Package | RJ | 10 |
| Mary Saveley | Lyon | Speedy Express | | 6 |
| Pascale Cartrain | Charleroi | United Package | | 40 |
| Mario Pontes | Rio de Janeiro | United Package | RJ | 20 |
| Yang Wang | Bern | United Package | | 15 |
| Michael Holz | Genève | Federal Shipping | | 20 |
| Paula Parente | Resende | United Package | SP | 15 |
| Carlos Hernández | San Cristóbal | Federal Shipping | Táchira | 25 |
| | | | | |
Config
public class OrderFilterTable : MvcTable<Order>
{
public override void Configure(IStaticTableConfiguration<Order> config)
{
config.SetAction("ListOrdersForFilters", "Northwind")
.SetCssClass("table table-striped")
.HiddenColumnFor(c => c.OrderID, cfg => cfg.Hide())
.DisplayForColumn(c => c.Customer.ContactName)
.DisplayForColumn(c => c.Customer.City)
.DisplayForColumn(c => c.Shipper.CompanyName)
.DisplayForColumn(c => c.ShipRegion)
.DisplayForColumn(c => c.Order_Details[0].Quantity)
.ConfigurePagingControl(p => p.SetContainerCssClass("pagination"));
}
}
Child Action
public ActionResult ListOrdersForFilters(TableRequestModel request, FiltersModel model)
{
var entities = new NorthwindEntities(NorthwindServiceUrl);
IQueryable<Order> orders =
entities.Orders.Expand(o => o.Customer).Expand(o => o.Shipper).Expand(o => o.Order_Details);
if (!String.IsNullOrEmpty(model.SelectedCustomerId))
{
orders = orders.Where(o => o.CustomerID == model.SelectedCustomerId);
}
return TableResult.From(orders).Build<OrderFilterTable>(request);
}