Adding sub-totals

Docs

Sub-totals can be added for a column using the TotalBreak property in combination with the Aggregate property. Duplicated column values can be suppressed using ClearDuplicateValue property for enhanced readability.

Razor
                                
                                        
DbNetGridCore orderTotalsGrid = new DbNetGridCore("northwind", "Customers join Orders on Customers.CustomerID = Orders.CustomerID join [Order Details] on Orders.OrderID = [Order Details].OrderID");
orderTotalsGrid.Columns = new List() { "CompanyName", "OrderDate", "[Order Details].OrderID", "ProductID", "UnitPrice", "Quantity", "(UnitPrice*Quantity) as Value" };
orderTotalsGrid.Labels = new List() {  "Company", "Order Date", "Order ID", "Product", "Unit Price", "Qty", "Value" };
orderTotalsGrid.Column("UnitPrice").Format("c");
orderTotalsGrid.Column("value").Format("c").DataType(typeof(Decimal)).Aggregate(AggregateType.Sum);
orderTotalsGrid.Column(new string[] { "CompanyName", "OrderID" }).TotalBreak();
orderTotalsGrid.Column("OrderDate").ClearDuplicateValue();
orderTotalsGrid.Column("ProductID").Lookup(new Lookup("Products", "ProductId", "ProductName"));
@orderTotalsGrid.Render()