Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]ASP.NET WebForms Controls
 [Collapse]ASP.NET MVC Extensions
  [Expand]Product Information
  [Expand]Getting Started
  [Expand]Common Concepts
  [Expand]Grid View
  [Expand]Card View
  [Collapse]Vertical Grid
    Overview - VerticalGrid
    Main Features
   [Collapse]Concepts
    [Collapse]Binding to Data
      Binding to Data via Entity Framework (Code First)
      Binding to Data via Entity Framework or LINQ to SQL (Database First)
      Binding to Large Data (Database Server Mode)
     [Collapse]Custom Data Binding
       Custom Data Binding - Overview
       Action Types and Passed Parameters
       Methods to Update the VerticalGrid State in Actions
       ProcessCustomBinding - Available Binding Delegates
       Implementation of Typed Method Delegates
       Custom Binding Limitations
    [Expand]Data Representation Basics
    [Expand]Data Editing and Validation
    [Expand]Focus and Navigation
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]HTML Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Navigation and Layout Extensions
  [Expand]File Management
  [Expand]Multi-Use Site Extensions
  [Expand]Charts
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Tree List
  [Expand]Data Editor Extensions
  [Expand]Report Extensions
  [Expand]SpellChecker
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Custom Data Binding - Overview

The VerticalGrid supports custom data binding that allows you to provide the extension with data manually. In this custom data binding mode, you have full control of and responsibility for populating the VerticalGrid with the required data each time the extension requests it.

Note

The Custom Data Binding mode was specially designed for working with a large data volume and handling all data shaping operations manually (e.g., it is impossible to use the built-in Linq/Entity Framework capabilities).

If there are no strict requirements for using Custom Data Binding, using one of the following data binding modes is recommended.

In brief, this mode requires that you manually populate a VerticalGrid-specific view model with the portion of data that needs to be currently displayed within the extension. You can accomplish this by performing the following steps.

  • Define Handling Actions
    In addition to a standard handling Action defined using the GridSettingsBase.CallbackRouteValues, use the VerticalGridSettings.CustomBindingRouteValuesCollection to specify additional Actions to handle all or specific data operations (paging, filtering, sorting), depending on which functionality is used in your VerticalGrid. Data operations are identified by the VerticalGridOperationType enumeration values.

  • Obtain/Update VerticalGrid State
    In Actions, use the VerticalGridExtension.GetViewModel static method to obtain the extension's view model, which is a specific VerticalGridModel object designed to maintain the VerticalGrid state and provide a means to populate itself with data. By default, the view model obtained within Actions contains the previous state of the VerticalGrid. If required, update this state with the state information that relates the processed operation and is automatically passed to an Action as a parameter. (For instance, this state can be a row state (VerticalGridRowState) that contains information on which row is sorted and in which direction/order, or a pager state (VerticalGridPagerState) that determines which page is selected.)

  • Delegate Model Population
    Within a Controller, use the VerticalGrid view model that contains the up-to-date VerticalGrid state and call its VerticalGridModel.ProcessCustomBinding method to delegate the implementation of a model population to certain Model-layer functions specified with method parameters.

  • Implement Model Population
    At the Model layer, implement certain delegates, which are pointed to by the VerticalGridModel.ProcessCustomBinding method's parameters to populate the VerticalGrid view model with a portion of the currently required data.

  • Bind the VerticalGrid to the Populated Model
    In a Controller, pass the populated view model object as a Model to the VerticalGrid's Partial View. In the Partial View, bind the extension to the passed Model by using the VerticalGridExtension.BindToCustomData method.

Note

When implementing the VerticalGrid's custom data binding, the DevExpressEditorsBinder must be used instead of the default model binder to correctly transfer values from DevExpress editors back to the corresponding data model fields. See the Binding to Model section in the Binding Data Editors to Data topic for more details on how to specify DevExpressEditorsBinder as a model binder.

These steps are described in greater detail below.

Expanded Define Handling Actions

To associate a VerticalGrid data operation type with a handling Action method, populate the extension's specific route values collection available using the VerticalGridSettings.CustomBindingRouteValuesCollection property. Register each data operation that you need to handle by adding a specific item to the collection. Within an item, identify a data operation and specify a handling method by providing its Controller and Action names.

Partial View Code:

Refer to the Action Types and Passed Parameters topic to learn more about available data operation types.

Expanded Obtain/Update VerticalGrid State

In each specified Action, you can obtain both the previous state of the VerticalGrid (the state the VerticalGrid had before an end-user performed the currently processed data operation) and the information (state) specific to the currently processed operation (for instance, information about the applied paging or sorted row). The VerticalGrid's previous state can be obtained as a VerticalGrid view model object (VerticalGridModel) by making a call to the static VerticalGridExtension.GetViewModel method. The currently processed data operation's state is automatically passed to each Action as its parameter(s). You can update the VerticalGrid view model object, maintaining the previous VerticalGrid state with the state of the currently processed operation to update the VerticalGrid state. Then, the updated VerticalGrid view model should be processed to populate it with the required data (see the next item for details).

Controller Code:

Refer to the Action Types and Passed Parameters topic to learn more on operation-specific parameters passed to handling Actions automatically.
See the Methods to Update the VerticalGrid State in Actions topic for a list of methods the VerticalGridModel exposes to update the VerticalGrid state.

Expanded Delegate Model Population

Given the VerticalGrid view model, call its VerticalGridModel.ProcessCustomBinding method to delegate the implementation of a model population to certain Model-layer functions specified with method parameters. The VerticalGridModel.ProcessCustomBinding method has several overloads. You can select one depending on which data operations you need to handle.

Controller Code:
Sample Model Code:

Refer to the ProcessCustomBinding - Available Binding Delegates topic to learn more about the VerticalGridModel.ProcessCustomBinding method.

Expanded Implement Model Population

At the Model layer, provide implementation for the specified method delegates according to your application needs and domain layer logic. Use arguments available through the e parameter of method delegates to obtain operation-related information and to supply the model with the required data.

Model Code:

Refer to the Implementation of Typed Method Delegates topic to learn more about the available arguments and the implementation of method delegates.

Expanded Bind the VerticalGrid to the Populated Model

The resulting populated VerticalGrid view model object should be returned as a Model to a Partial View that contains the VerticalGrid markup. To bind the VerticalGrid to this view model, use the VerticalGridExtension.BindToCustomData method within the extension's Partial View.

Controller Code:
Partial View Code:

Expanded See Also

How would you rate this topic?​​​​​​​