Navigation: DbNetGridCore >

Properties

 

 

 

 

 

AutoRowSelect (boolean)

 

Controls the automatic selection of the first row after each page is loaded. By default this property is set to true

 

Demo

 

BooleanDisplayMode (enum)

 

Controls the way boolean values are displayed in the grid. Valid values are as follows:

 

TrueFalse - Default convertion of a boolean value to a string

YesNo - Natural language equivalient of True/False (as defined in the resource file)

Checkbox - A checkbox icon

 

Demo

 

Columns (List<string>)

 

Defines the names of the columns to be selected from the table(s) and/or view(s). If there is more than one column with the same name in the data source

 

...

customersGrid.Columns = new List<string>() { "CompanyName", "Address + ', ' + City as Addr", "Country", "Phone + '/' + Fax as PhoneFax" };

...

ordersGrid.Columns = new List<string>() { "Customers.CompanyName", "Orders.OrderDate", "[Order Details].OrderID", "[Order Details].ProductID", "[Order Details].UnitPrice", "[Order Details].Quantity" };

...

 

Demo

 

Connection (string)

 

The Connection property is the name of the database connection string in the appSettings.json file e.g.

 

   "ConnectionStrings": {

    "chinook (sqlite)": "Data Source=~/data/chinook.db;Cache=Shared",

    "northwind (mssql)": "server=localhost;database=Northwind;trusted_connection=true;",

    "pubs (mssql)": "server=localhost;database=Pubs;trusted_connection=true;",

    "AdventureWorks (mssql)": "server=localhost;database=AdventureWorks;trusted_connection=true;",

    "sakila (mysql)": "server=localhost;port=3306;database=sakila;user=root;password=password1234;",

    "sakila (postgresql)": "Server=127.0.0.1;Port=5432;Database=dvdrental;User Id=postgres;Password=password1234;"

  },

 

Currently the following databases are supported: MS SQL Server, MySql, MariaDb, PostgreSQL and SQLite

 

Copy (boolean)

Controls the presence of the Copy button in the toolbar which allows the use to copy the current page to the clipboard

 

Culture (string)

Allows override of the default culture which controls the default date and currency formatting and also translation where available

 

Demo

 

DatabaseType(enum)

DbNetGridCore can be used with a number of databases and in the case of MS SQL Server and SQLite you can normally rely on the control automatically recognising the database type from the connection string. For other database types we recommend specifying the database type explicitly either as a property or in the constructor.

 

...

DbNetGridCore storeGrid = new DbNetGridCore("sakila(mysql)", "store")

{

    DatabaseType = DatabaseType.MySQL

};

...

 

Delete (boolean)
Controls the presence of the Delete button in the toolbar which allows the user to delete the currently selected row. Requires the presence of a column defined as a primary key

 

EditControl (DbNetEditCore)
If the Insert or Update properties are set to true then and instance of the edit control is created and can be configured using this property

...

employeesGrid.EditControl.LayoutColumns = 2;

employeesGrid.EditControl.Column("notes").ControlType(EditControlType.TextArea).Hidden().DataType(typeof(string));

employeesGrid.EditControl.Column("ReportsTo").Lookup(new Lookup("employees", "employeeid", "lastname + ', ' + firstName"));

employeesGrid.EditControl.Bind(EventType.OnFormElementCreated, "configureFormElement");

...

 

Demo

 

Export (boolean)
Controls the presence of the Export button in the toolbar which allows the user to export all the data to HTML or Excel

 

FixedFilterParams(dictionary<string,object>)

The FixedFilterParams property is used to assign parameters values for an parameters included in the FixedFilterSql property.

 

...

ordersGrid.FixedFilterSql = "CustomerId = @CustomerId";

ordersGrid.FixedFilterParams["CustomerId"] = Model.CustomerId;

...

 

 

FixedFilterSql(string)
 

The FixedFilterSql property is used to assign a fixed filter to the query that restricts the rows returned to the grid from the data source. The property can be parameterized with values supplied with the FixedFilterParams property

Demo


FromPart (string)

 

The FromPart property can be the name of any table, view or stored procedure (that returns rows) or multiple tables and/or views (with any join information included) that occur in the database . The following are all valid assignments to the FromPart property

 

...

// Table data source

DbNetGridCore productsGrid = new DbNetGridCore("northwind", "Products");

...

// Joined tables data source

DbNetGridCore ordersGrid = new DbNetGridCore("northwind", "Customers join Orders on Customers.CustomerID = Orders.CustomerID join [Order Details] on Orders.OrderID = [Order Details].OrderID");

...

// Stored procedure data source

DbNetGridCore salesForYearGrid = new DbNetGridCore("northwind(msql)", "[Sales by Year]", null, ataSourceType.StoredProcedure);

 

 

FrozenHeader (boolean)


If set to true then the header part of the grid will visible instead of scrolling of the screen so the use can still sort by clicking on the headings or use an column filters.
 

Demo

 

GoogleChartOptions(GoogleChartOptions)

 

Enables the configuration of a Google chart that represents the grid data

...

productSalesSummaryGrid.GoogleChartOptions = new GoogleChartOptions() { Type = GoogleChartType.PieChart, PanelId = "piechart", FunctionName = "chartOptions" };

...
<script type="text/javascript" class="source">

        function chartOptions(grid, options) {

            options.is3D = true;

            options.chartArea = { width: '90%', height: '90%' };

            options.width = 300;

            options.height = 250;

        }

</script>
...


Demo

 

GroupBy (boolean)


If set to true then the grid will group the data by all the columns that are not defined as aggregates
 

Demo

 

Height(int)


Sets the height of the grid table in pixels (scrolling the rows under the headings if the height is exceeded). Typically used to allow lots of rows to be navigated by scrolling instead of paging.

 

Demo

 

Id (string) 

 

This is the Id of the containing HTML element on the page. It can be supplied as the 3rd optional argument to the constructor if you want to render the grid inside an exisitng element. Otherwise the Id is generated and given the HTML element that the control will created at the point at which the Render method is called.

 

...

 <div class="tab-pane fade" id="orderdetails" role="tabpanel" aria-labelledby="orderdetails-tab">

     <div id="orderDetailsGrid"></div>

 </div>

...

DbNetGridCore orderDetailsGrid = new DbNetGridCore("northwind", "[order details]", "orderDetailsGrid");

...

 

Demo

 

InitialOrderBy (string) 

 

Assigns the name of the column by which the records in the grid will be initially ordered. The order can be overridden by clicking on the grid column header after the initial load.

...

productsGrid.InitialOrderBy = "unitprice desc";

...

 


Insert (boolean)
Controls the presence of the Insert button in the toolbar which allows the user to add a new row to the table using the Edit Dialog

Demo

 

 

Labels (List<string>)

 

Defines the labels for the columns to be selected from the table(s) and/or view(s).

 

...

customersGrid.Labels = new List<string>() { "Company Name", "Address", "Country", "Phone/Fax" };

...

ordersGrid.Labels = new List<string>() { "Company Name", "Order Date", "Order ID", "Product", "Unit Price", "Qty" };

...

 

Demo

 

MaxImageHeight(integer)

Specifies the maximum height of any image rendered in grid.


Demo

 

MultiRowSelect (boolean)


If set to true then the grid will allow the selection of multiple rows using a checkbox for each row

 

Demo

 

MultiRowSelectLocation (enum)

 

Configures the location of the selection box column to be on the Left (default) or Right of the grid
 

Demo

 

Navigation(bool)

 

Controls the presence of the navigation display and buttons in the toolbar. Setting to false will cause all the records to be selected and rendered a single page.

 

...

employeesGrid.Navigation = false;

...


Demo

 

NestedGrid (DbNetGridCore)

 

Assigns a refererence to another instance of DbNetGridCore that will be rendered as a nested child of this grid. In order to only select the records in the nested grid that are linked to the parent row it is necessary to identify the foreign key column in the nested grid using the ForeignKey column method.

 

...

DbNetGridCore customersGrid = new DbNetGridCore("northwind", "customers");

...

DbNetGridCore ordersGrid = new DbNetGridCore("northwind", "orders");

...

ordersGrid.Column("CustomerID").ForeignKey().Hidden();

...

customersGrid.NestedGrid = ordersGrid;

...

 

Demo

 

 

OptimizeForLargeDataset (boolean)


If set to true then the grid performance will be optimised for a large dataset (100,000+ rows) to ensure optimal loading time.

 

 

PageSize (integer)

 

Set the number of rows displayed per page (default is 20). Setting the PageSize to -1 will have the effect of selecting all the records as a single page. The same effect can be achieved by setting the Navigation property to false
 

...

DbNetGridCore ordersGrid = new DbNetGridCore("northwind", "orders", "ordersGrid")

{

    Columns = new List<string>() { "OrderID", "CustomerID", "EmployeeID", "OrderDate", "RequiredDate", "ShippedDate", "ShipVia", "Freight" },

    Labels = new List<string>() { "Order ID", "Customer ID", "Employee", "Date Ordered", "Date Required", "Date Shipped", "Ship Via", "Freight" },

    PageSize = 10

};

...


Demo

 

ProcedureParams (Dictionary<string,object>)

 

Allows you to set the parameter values when using a Stored Procedure as the data source

 

...

DbNetGridCore salesForYearGrid = new DbNetGridCore("northwind(msql)", "[Sales by Year]", null, DataSourceType.StoredProcedure);

salesForYearGrid.ProcedureParams["beginning_date"] = new DateTime(2023, 1, 1);

salesForYearGrid.ProcedureParams["ending_dates"] = new DateTime(2024, 1, 1);

salesForYearGrid.Column("subtotal").Format("c");

@salesForYearGrid.Render()

...

 

 

QuickSearch (boolean)

 

Controls the presence of the "quick search" search box in the toolbar which will search across all the alphanumeric columns in the grid

 

...

DbNetGridCore customersGrid = new DbNetGridCore("northwind", "customers")

{

    QuickSearch = true

};

@customersGrid.Render()

...

 

Demo

 

RowSelect (boolean)

 

Controls the highlighting of the row when a user clicks on it. The default is true.

 

Demo

 

Search (boolean)

 

Controls the presence of the Search button in the toolbar which opens the search dialog

 

ToolbarButtonStyle (ToolbarButtonStyle)

 

Controls the style of the toolbar buttons using the ToolbarButtonStyle enum

 

...

DbNetGridCore customersGrid = new DbNetGridCore("northwind", "customers")

{

    ToolbarPosition = ToolbarPosition.Bottom,

    ToolbarButtonStyle = ToolbarButtonStyle.ImageAndText

};

 

@customersGrid.Render()

...

 

Demo

 

ToolbarPosition (ToolbarPosition)

 

Controls the position of the toolbar using the ToolbarPosition enum

 

If the toolbar is Hidden then all selected rows will be shown as a single page

 

Demo

 

Update (boolean)

Controls the presence of the Update button in the toolbar which allows the user to update the current row using the Edit Dialog

 

Demo

 

View (boolean)

Controls the presence of the View button in the toolbar which will open the View dialog. Columns appearing in the View dialog can be controlled using the View column property

 

Demo

 

ViewLayoutColumns (boolean)

Controls the number of columns the fields in the View dialog are distributed over

 

Demo

 

 

 

Copyright © 2023 DbNetLink