Client-side events

Docs

Client-side events can be used to customise the grid after it has been rendered. In this example values are highlighted if the stock is less than the re-order level

Loading...
Razor code

GridModel productGrid = new GridModel(DataSourceType.SQLite, "Northwind", "Products") { ViewDialog = new ViewDialog() { LayoutColumns = 2 } };
productGrid.Columns = new List()
{
    new GridColumn("ProductID") { PrimaryKey = true },
    new GridColumn("ProductName"),
    new GridColumn("SupplierID","Supplier") { Lookup = new Lookup("Suppliers", "SupplierId", "CompanyName"), Filter = true },
    new GridColumn("CategoryID","Category") { Lookup = new Lookup("Categories", "CategoryID", "CategoryName"), Filter = true },
    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)}
};
productGrid.Bind(ClientEvent.RowTransform, "highlightGridLowStock");
productGrid.Bind(ClientEvent.ViewDialogUpdated, "highlightViewLowStock");

@(await new DbNetSuiteCore.GridControl(HttpContext).Render(productGrid))