Back to Devexpress

GridSettingsBase.CallbackRouteValues Property

aspnetmvc-devexpress-dot-web-dot-mvc-dot-gridsettingsbase.md

latest8.2 KB
Original Source

GridSettingsBase.CallbackRouteValues Property

Defines the callback routing logic by specifying the names of a Controller and an Action which should handle callbacks.

Namespace : DevExpress.Web.Mvc

Assembly : DevExpress.Web.Mvc5.v25.2.dll

NuGet Package : DevExpress.Web.Mvc5

Declaration

csharp
public object CallbackRouteValues { get; set; }
vb
Public Property CallbackRouteValues As Object

Property Value

TypeDescription
Object

An object containing the Controller and Action names.

|

Remarks

Example

The following example illustrates how to use the CallbackRouteValues property.

Note

For a full example, see the Grid View - Sorting demo.

cshtml
@Html.DevExpress().GridView(settings => {
    settings.Name = "gvSorting";
    settings.CallbackRouteValues = new { Controller = "GroupingSorting", Action = "SortingPartial" };
    settings.Width = Unit.Percentage(100);

    settings.Columns.Add("ContactName").SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
    settings.Columns.Add("CompanyName");
    settings.Columns.Add("City");
    settings.Columns.Add("Region");
    settings.Columns.Add("Country");

    DevExpress.Web.Demos.GridViewFeaturesHelper.SetupGlobalGridViewBehavior(settings);
}).Bind(Model).GetHtml()
csharp
public partial class GroupingSortingController: DemoController {
    public ActionResult Sorting() {
        return DemoView("Sorting", NorthwindDataProvider.GetCustomers());
    }
    public ActionResult SortingPartial() {
        return PartialView("SortingPartial", NorthwindDataProvider.GetCustomers());
    }
}

The CallbackRouteValues property allows you to pass only simple data (that do not require serialization) to the controller. If you need to send complex data, use one of the following approaches.

  1. Use the CallbackRouteValues collection to pass only the information that is required to recreate your complex model instance in the controller action (e.g., row keys or unique identifiers).
  2. Convert your complex model class into a simple data type. For instance, use the JSON encoding to pass the model to the controller as a string. Then, in the controller code, decode the passed value to get the model.
cshtml
@Html.DevExpress().GridView(settings => {  
    settings.Name = "GridView";  
    ...  
    settings.CallbackRouteValues = new {  
        Controller = "Home",  
        Action = "IndexPartial",  
        myComplexData = Json.Encode(Model.myListData)  
    };  
}).GetHtml()
csharp
public ActionResult IndexPartial(string SelectedIds) {  
    List<int> myData = System.Web.Helpers.Json.Decode<List<int>>(myComplexData);  
    ...  
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the CallbackRouteValues property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

asp-net-mvc-grid-export-colored-grid-in-wysiwyg-mode/CS/Controllers/HomeController.cs#L45

csharp
settings.Name = "gvProducts";
settings.CallbackRouteValues = new { Controller = "Home", Action = "GridViewPartialProducts" };

asp-net-mvc-grid-export-selected-columns-in-BeforeExport-event-handler/CS/E3352/Controllers/HomeController.cs#L47

csharp
gridVieewSettings.KeyFieldName = "ID";
gridVieewSettings.CallbackRouteValues = new { Controller = "Home", Action = "GridViewPartial" };

asp-net-mvc-grid-export-colored-grid-in-data-aware-mode/CS/Controllers/HomeController.cs#L55

csharp
settings.Name = "gvProducts";
settings.CallbackRouteValues = new { Controller = "Home", Action = "GridViewPartialProducts" };

mvc-gridview-export-data-to-different-formats/CS/Controllers/HomeController.cs#L57

csharp
settings.Name = "gvTypedListDataBinding";
settings.CallbackRouteValues = new { Controller = "Home", Action = "TypedListDataBindingPartial" };

asp-net-mvc-grid-export-hide-and-add-columns/CS/E4915/Controllers/HomeController.cs#L31

csharp
settings.Name = "GridView";
settings.CallbackRouteValues = new {
    Controller = "Home",

asp-net-mvc-grid-export-colored-grid-in-wysiwyg-mode/VB/Controllers/HomeController.vb#L52

vb
settings.Name = "gvProducts"
settings.CallbackRouteValues = New With {Key .Controller = "Home", Key .Action = "GridViewPartialProducts"}

asp-net-mvc-grid-export-colored-grid-in-data-aware-mode/VB/Controllers/HomeController.vb#L64

vb
settings.Name = "gvProducts"
settings.CallbackRouteValues = New With {Key .Controller = "Home", Key .Action = "GridViewPartialProducts"}

mvc-gridview-export-data-to-different-formats/VB/Controllers/HomeController.vb#L53

vb
settings.Name = "gvTypedListDataBinding"
settings.CallbackRouteValues = New With {.Controller = "Home", .Action = "TypedListDataBindingPartial"}
settings.KeyFieldName = "ID"

asp-net-mvc-grid-export-hide-and-add-columns/VB/E4915/Controllers/HomeController.vb#L30

vb
settings.Name = "GridView"
settings.CallbackRouteValues = New With {.Controller = "Home", .Action = "GridViewPartial"}
settings.KeyFieldName = "ProductID"

See Also

Grid View

Card View

Get Started

Callback-Based Functionality

GridSettingsBase Class

GridSettingsBase Members

DevExpress.Web.Mvc Namespace