Navigation: DbNetGridCore >

Methods

 

 

 

 

AddJson<T>(string json, HttpContext httpContext = null),

AddJson(string json, HttpContext httpContext = null)

 

This method can be used when you specify JSON as the data source type in the Constructor and want to assign the JSON data as a string. The method can be invoked either as a generic method passing type information or as plain method where type information is derived from the data. JSON date values for example are typically not recognised as DateTime values. The method takes a second optional parameter of HttpContext which if supplied causes the JSON to be cached on the server for the duration of the session instead of being sent to the server every time.

 

...

DbNetGridCore employeesGrid = new DbNetGridCore(DataSourceType.JSON);

employeesGrid.AddJson<Employee>(Model.JsonData); // typed

...

 

...

DbNetGridCore employeesGrid = new DbNetGridCore(DataSourceType.JSON);

employeesGrid.AddJson(Model.JsonData); // untyped

...

 

AddList<T>(IEnumerable<T> list, HttpContext httpContext = null)

 

This generic method can be used when you specify List as the data source type in the Constructor and want to assign the data as a list of typed objects.  The method takes a second optional parameter of HttpContext which if supplied causes the list data to be cached on the server for the duration of the session instead of being sent to the server every time.

 

...

DbNetGridCore productsGrid = new DbNetGridCore(DataSourceType.List);

productsGrid.AddList<Product>(Model.Products);

...

 

Demo

 

AddLinkedControl(DbNetSuiteCore)

 

This method takes an instance of DbNetGridCore or DbNetEditCore  as a parameter and makes it a child of the grid on which the method is called. The child control will then select all the records where the foreign key of the child control matches the primary key of the parent grid.

 

...

customersGrid.AddLinkedControl(ordersGrid);

...

 

...

customersGrid.AddLinkedControl(ordersEdit);

...

 

Demo  Demo

 

 

Bind(EventType, string)

 

This method assigns a client-side JavaScript method to a client-side grid event which enables additonal levels of customisation. The method is passed 2 arguments. The first is the type of the event and the second is the name of the JavaScript function that will be called by the event. The JavaScript function is always passed an instance of the client-side grid control and an optional second argument that contains additional information specific to the type of event. For more information about each event type click here

 

...

employeesGrid.Bind(EventType.OnInitialized, "saveGridReference");

employeesGrid.Bind(EventType.OnCellTransform, "transformNotes");

...

 

Column(string) : DbNetGridCoreColumn,

Column(string[]) : DbNetGridCoreColumn

 

The Column method creates a DbNetGridCoreColumn object which can be used to assign properties to a column or columns in the grid using a fluent style API

 

...

productsGrid.Column(new String[] { "ProductID", "ProductName", "SupplierID", "CategoryID", "QuantityPerUnit", "UnitPrice", "UnitsInStock", "UnitsOnOrder", "ReorderLevel", "Discontinued" }).Filter();

productsGrid.Column("SupplierID").Lookup(new Lookup("Suppliers", "SupplierId", "CompanyName"));

productsGrid.Column("CategoryID").Lookup(new Lookup("Categories", "CategoryId", "CategoryName")).FilterMode(FilterMode.List);

productsGrid.Column("UnitPrice").Format("c");

...

 

Demo

 

Render()

 

This method is called after the component has been fully configured and will render the grid at the point in the Razor page at which it is invoked unless the optional 3rd Id parameter is supplied to the constructor in which case the grid will be rendered inside the HTML element with the Id specified.

 

 

 

 

Copyright © 2023 DbNetLink