Specifying Columns

You can control the columns selected from the table or view by defining GridColumn objects and adding them the Columns property. In this example columns are selected and combined in an expression and also given a Label.

Loading...
Razor code

GridModel customerGrid = new GridModel(DataSourceType.SQLite, "northwind", "Customers");
customerGrid.Columns = new List
{
    new GridColumn("CompanyName", "Name"), // First argument is the expression, second is the label
    new GridColumn("coalesce(Address,'') || ', ' || coalesce(City,'')", "Address") { DataType = typeof(string)},
    new GridColumn("coalesce(Phone,'') || '/' || coalesce(Fax,'')", "Phone/Fax") { DataType = typeof(string)}
};
@(await new DbNetSuiteCore.GridControl(HttpContext).Render(customerGrid))