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. |
Help |
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.SetColumnFormat("UnitPrice", "c");
orderTotalsGrid.SetColumnFormat("value", "c");
orderTotalsGrid.SetColumnDataType("value", typeof(Decimal));
orderTotalsGrid.SetColumnAggregate("value", AggregateType.Sum);
orderTotalsGrid.SetColumnTotalBreak(new string[] { "CompanyName", "OrderID" });
orderTotalsGrid.SetColumnClearDuplicateValue(new string[] { "OrderDate" });
orderTotalsGrid.SetColumnLookup("ProductID", new Lookup("Products", "ProductId", "ProductName"));
@orderTotalsGrid.Render()