Action Types and Passed Parameters

  • 6 min to read

When you use the GridView in custom binding mode, provide the grid with data manually, upon each grid request. The GridView sends requests to the server via callbacks (see Using Callbacks). Each callback type should be associated with a handling Action in a Controller. You can define callback routing logic by using specific properties exposed by the grid. This topic provides information about the available callback routing properties of the GridView and specifies which particular Actions should be handled in custom binding mode.

Callback Routing Properties

In general, the GridView has the following properties that allow you to define callback routing logic for different actions. The table below describes which properties and corresponding Actions relate to the custom binding implementation of the grid.

Name

Description

Required for custom data binding?

Action accepts binding parameter(s)?

GridSettingsBase.CallbackRouteValues

Specifies the names of the Controller and the Action that handle standard grid callbacks.

The GridView automatically updates (re-renders) itself after each standard callback, so it is necessary to provide the grid with data during standard callback processing.

Handling the specified Action is essential to implement the grid's custom data binding; no specific custom binding parameter is automatically passed to the Action.

Yes

No

GridViewSettings.CustomBindingRouteValuesCollection

Specifies the names of Controllers and Actions that handle callbacks related to grid data operations such as paging, sorting, grouping and filtering.

Handling all or some of these data operations is essential to implement the grid's custom data binding. Operation-specific parameters are automatically passed to the specified Action(s).

Yes

Yes

GridSettingsBase.CustomActionRouteValues

Specifies the names of the Controller and the Action that handle custom callbacks initiated by the MVCxClientGridView.PerformCallback client method.

The GridView automatically updates (re-renders) itself after this custom callback, so it is necessary to provide the grid with data during callback processing.

If the MVCxClientGridView.PerformCallback client method is used in your project, it is essential to handle the specified Action to implement the grid's custom data binding. The specified Action only accepts a parameter passed via the PerformCallback client method. No specific custom binding parameter is automatically passed to the Action.

Only if the MVCxClientGridView.PerformCallback client method is manually called on the client side.

No

GridSettingsBase.CustomDataActionRouteValues

Specifies the names of the Controller and the Action that handle custom data callbacks initiated by the MVCxClientGridView.GetValuesOnCustomCallback client method.

The GridView does not automatically update (re-render) itself after this custom data callback, so it is not necessary to provide the grid with data during callback processing.

Handling the specified Action is not required to implement the grid's custom data binding. No specific custom binding parameter is automatically passed to the Action.

No

No

Action Types and Parameters that are Specific to Custom Binding

The GridViewSettings.CustomBindingRouteValuesCollection property allows you to assign particular handling Actions for four data operations - Paging, Sorting, Grouping and Filtering - which are specifically exposed to be handled in a custom manner to implement custom data binding of the GridView. These operations are identified by values of the GridViewOperationType enumeration. The table below lists the available data operation types, and provides additional information on how to assign and declare Actions that handle these operations.

Operation Type

Description

Syntax to Assign and Declare Action

Parameters Passed to Action

GridViewOperationType.Paging

An operation of this type is initiated if the paging-related state of the grid is changed. For instance, an end-user moves to another grid page (by clicking a pager navigation button or page number button) or changes the grid's page size (using the pager's page size combo box).

Partial View Code:

@Html.DevExpress().GridView( settings => { ... settings.CustomBindingRouteValuesCollection.Add( GridViewOperationType.Paging, new { Controller = "MyController", Action = "MyPagingAction" } ); ...

Controller Code:

public ActionResult MyPagingAction(GridViewPagerState pager) {}

GridViewOperationType.Sorting

An operation of this type is initiated if the sorting-related state of the grid is changed. For instance, an end-user sorts a column by clicking its header.

Note that a regular click on a column header clears the sort settings on other columns. To preserve the existing sort settings of other columns, an end-user can hold the SHIFT key down while clicking. This can be useful when sorting against multiple columns.

Partial View Code:

@Html.DevExpress().GridView( settings => { ... settings.CustomBindingRouteValuesCollection.Add( GridViewOperationType.Sorting, new { Controller = "MyController", Action = "MySortingAction" } ); ...

Controller Code:

public ActionResult MySortingAction(GridViewColumnState column, bool reset) {}

  • column of type GridViewColumnState

    Represents the current state of the column related to the performed sort operation.

     

  • reset of type Boolean

    Determines whether the performed sort operation requires a reset of the previous sorting state.

    true if the SHIFT key was not pressed during the performed sort operation and the previous sorting state should be reset;

    false if the sort operation was performed with the SHIFT key pressed and the previous sorting state should be preserved.

GridViewOperationType.Grouping

An operation of this type is initiated if the grouping-related state of the grid is changed. For instance, an end-user moves a column header to the group panel to group grid data by values of the column.

Partial View Code:

@Html.DevExpress().GridView( settings => { ... settings.CustomBindingRouteValuesCollection.Add( GridViewOperationType.Grouping, new { Controller = "MyController", Action = "MyGroupingAction" } ); ...

Controller Code:

public ActionResult MyGroupingAction(GridViewColumnState column) {}

  • column of type GridViewColumnState

    Represents the current state of the column related to the performed group operation.

GridViewOperationType.Filtering

An operation of this type is initiated if the filtering-related state of the grid is changed.

An end-user can apply a filter condition to a single column - by using a column's header filter dropdown or by typing in the auto filter row working in the Auto mode.

Or, an end-user can filter multiple columns at once - by clicking the auto filter row's Apply or Clear button or by using the built-in Filter Builder.

Partial View Code:

@Html.DevExpress().GridView( settings => { ... settings.CustomBindingRouteValuesCollection.Add( GridViewOperationType.Filtering, new { Controller = "MyController", Action = "MyFilteringAction" } );

Controller Code:

public ActionResult MyFilteringAction(GridViewFilteringState filteringState) {}

Controller Code (OBSOLETE):

An obsolete approach that is in effect when only one column is being filtered:

public ActionResult MyFilteringAction(GridViewColumnState column) {}

  • filteringState of type GridViewFilteringState

    Represents the current state of the applied filter (contains the filter expression and the affected column/columns).

If an obsolete approach is used:

  • column of type GridViewColumnState

    Represents the current state of the column related to the performed filter operation.

Note: When implementing the grid'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.