Bind Vertical Grid to Large Data (Database Server Mode)
- 3 minutes to read
Database Server Mode Overview
The MVC VerticalGrid extension supports a specific binding mode designed to work with large datasets. Within this binding mode, data-aware operations (sorting, grouping, etc.) are performed on the database server side, which is why this mode is called database server mode.
In database server mode, the MVC VerticalGrid is bound to a queryable source using the VerticalGridExtension.BindToLINQ method, which allows the VerticalGrid to load data from the queryable source on demand.
When an end-user performs data operations (sorting, grouping, etc.), the VerticalGrid generates smart queries to receive only those records that must be displayed on screen. These requests are passed to the associated queryable source. The queryable source translates these requests into the required queries and executes them. This ensures a quick response and improved performance for large data sources.
For end-users, the MVC VerticalGrid functions identically in regular and server modes. In database server mode, end-users can use an automatic filtering feature to access a specific data range, sort, group and filter data, calculate summaries, etc.
Binding to Data
Perform the following steps to bind the VerticalGrid to a data source in database server mode.
Add the VerticalGrid to your project
Add the VerticalGrid to your project, and bind it to a data source in regular mode using the Code First development approach or Database First development approach.
Change the View code
In the VerticalGrid’s View code, use the VerticalGridExtension.BindToLINQ method to bind the VerticalGrid to a data source. This enables binding to data in database server mode.
@Html.DevExpress().VerticalGrid(settings => { settings.Name = "VerticalGrid"; settings.CallbackRouteValues = new { Controller = "Home", Action = "VerticalGridPartial" }; //... }).BindToLINQ(string.Empty, string.Empty, (s, e) => { e.QueryableSource = LargeDatabaseDataProvider.DB.Emails; }).GetHtml()
Note
Enable the VerticalGridSettings.EnableRecordsCache option to reduce the number of calls to a bound data source when the VerticalGrid functions in Database Server Mode. When the VerticalGrid extension functions in regular data binding mode, the VerticalGridSettings.EnableRecordsCache option should be disabled.
Server mode limitations
In server mode, the MVC VerticalGrid does not have simultaneous access to bound data in its entirety. This imposes some limitations on the VerticalGrid’s features that are still available in regular binding mode. see the table below for information on features that have limitations in server mode.
- Custom sorting (using VerticalGridSettings.CustomRowSort) and sorting by displayed values are not supported.
- Filtering by displayed values is not supported. Only filtering by edit values is allowed.
- Case-sensitive filtering. The extension converts a search string to lower-case before filtering.
- Custom summary calculation (using VerticalGridSettings.CustomSummaryCalculate) is not supported.
- You can only enable sorting, filtering and summary calculation for unbound rows that are populated using expressions (see VerticalGridDataRow.UnboundExpression).
- Selection of all grid rows using the built-in SelectAll check box (when the VerticalGridCommandRow.SelectAllCheckboxMode property is set to GridViewSelectAllCheckBoxMode.AllPages) is not supported.