Grid form |
For a Form with multiple records you can increase the visibility of the dataset by linking the Form control to a parent Grid control using the LinkedControl property. This also adds the enhanced navigation, sorting and filtering capabilities which can be particularly helpful with larger number of records. The sample also demonstrates use of the Required, InitialValue, MinValue and MaxValue column properties |
Loading...
Loading...
Razor code
GridModel productsGrid = new GridModel(DataSourceType.SQLite, "FormNorthwind(sqlite)", "Products") { ViewDialog = new ViewDialog() { LayoutColumns = 2 }, PageSize = 5 };
productsGrid.Columns = new List() {
new GridColumn("ProductID") { PrimaryKey = true },
new GridColumn("ProductName"),
new GridColumn("SupplierID","Supplier") { Lookup = new Lookup("Suppliers", "SupplierId", "CompanyName"), Filter = FilterType.Default },
new GridColumn("CategoryID","Category") { Lookup = new Lookup("Categories", "CategoryID", "CategoryName"), Filter = FilterType.Default },
new GridColumn("QuantityPerUnit", "Qty."),
new GridColumn("UnitPrice","Price") { Format = "c"},
new GridColumn("UnitsInStock", "Stock"),
new GridColumn("UnitsOnOrder","On Order"),
new GridColumn("ReorderLevel"),
new GridColumn("Discontinued") { DataType = typeof(Boolean), Filter = FilterType.Default, LookupEnum = typeof(DiscontinuedEnum)}
};
FormModel productForm = new FormModel(DataSourceType.SQLite, "FormNorthwind(sqlite)", "Products") { Insert = true, Delete = true, ToolbarPosition = ToolbarPosition.Bottom, Caption = "Products" };
productForm.Columns = new List() {
new FormColumn("ProductID","ID") { ForeignKey = true },
new FormColumn("ProductName", "Name"),
new FormColumn("SupplierID","Supplier") { Lookup = new Lookup("Suppliers", "SupplierId", "CompanyName"),Required = true },
new FormColumn("CategoryID","Category") { Lookup = new Lookup("Categories", "CategoryID", "CategoryName"),Required = true},
new FormColumn("QuantityPerUnit", "Qty"){ InitialValue = 0},
new FormColumn("UnitPrice", "Price") {Required = true,InitialValue = 0, MinValue = 0, MaxValue = 100 },
new FormColumn("UnitsInStock", "Stock") {Required = true,InitialValue = 0, MinValue = 0 },
new FormColumn("UnitsOnOrder", "On Order") {Required = true,InitialValue = 0 },
new FormColumn("ReorderLevel", "Re-order Level") {Required = true,InitialValue = 0, MaxValue = 50 },
new FormColumn("Discontinued") {DataType = typeof(bool), InitialValue = false, LookupEnum = typeof(DiscontinuedEnum)}
};
productsGrid.LinkedControl = productForm;
@(await new DbNetSuiteCore.Control(HttpContext).Render(productsGrid))
@(await new DbNetSuiteCore.Control(HttpContext).Render(productForm))