Linking grids |
Docs
At it's most basic you can generate a grid by simply specifying the connection alias and the name of the table or view. Default functionality includes a search box that will perform a wildcard search against all string based columns in the dataset, the ability to sort on any column by clicking on the heading, a copy page button and an option to export the data in HTML, Excel, CSV and PDF formats. |
Loading...
Loading...
Loading...
Razor code
var customerColumns = new List
{
new GridColumn("customerid", "CustomerID") {PrimaryKey = true },
new GridColumn("firstname", "Forename"),
new GridColumn("lastname", "Surname"),
new GridColumn("email", "Email Address") {Format = FormatType.Email },
new GridColumn("address", "Address"),
new GridColumn("city", "City") { InitialSortOrder = SortOrder.Desc},
new GridColumn("postalcode", "Post Code")
};
var invoiceColumns = new List
{
new GridColumn("invoiceid", "Invoice ID") {PrimaryKey = true },
new GridColumn("customerid", "Customer ID") {ForeignKey = true, DataOnly = true },
new GridColumn("invoicedate", "Date"),
new GridColumn("billingaddress", "Address"),
new GridColumn("billingcity", "City"),
new GridColumn("billingstate", "State"),
new GridColumn("billingcountry", "Country"),
new GridColumn("billingpostalcode", "Post Code")
};
var invoiceItemColumns = new List
{
new GridColumn("invoicelineid", "Line ID"),
new GridColumn("invoiceid", "Invoice ID") {ForeignKey = true, DataOnly = true },
new GridColumn("trackid", "Track ID") {Lookup = new Lookup("tracks","trackid","name")},
new GridColumn("unitprice", "Price") {Format = "C"},
new GridColumn("quantity", "Qty")
};
var invoiceLineGrid = new GridModel("Invoice_items");
invoiceLineGrid.Columns = invoiceItemColumns;
invoiceLineGrid.Caption = "Invoice Lines";
invoiceLineGrid.PageSize = 5;
invoiceLineGrid.ToolbarPosition = ToolbarPosition.Hidden;
var invoiceGrid = new GridModel("Invoices");
invoiceGrid.Columns = invoiceColumns;
invoiceGrid.LinkedGrid = invoiceLineGrid;
invoiceGrid.Caption = "Invoices";
invoiceGrid.PageSize = 5;
invoiceGrid.ToolbarPosition = ToolbarPosition.Hidden;
var customerGrid = new GridModel(DataSourceType.SQLite, "Chinook(sqlite)", "Customers");
customerGrid.Columns = customerColumns;
customerGrid.LinkedGrid = invoiceGrid;
customerGrid.PageSize = 5;
@(await new DbNetSuiteCore.GridControl(HttpContext).Render(customerGrid))
@(await new DbNetSuiteCore.GridControl(HttpContext).Render(invoiceGrid))
@(await new DbNetSuiteCore.GridControl(HttpContext).Render(invoiceLineGrid))