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.v23.1.dll
NuGet Package: DevExpress.Web.Mvc5
Declaration
Property Value
Type | Description |
---|---|
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.
@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()
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.
- 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).
- 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.
@Html.DevExpress().GridView(settings => {
settings.Name = "GridView";
...
settings.CallbackRouteValues = new {
Controller = "Home",
Action = "IndexPartial",
myComplexData = Json.Encode(Model.myListData)
};
}).GetHtml()
public ActionResult IndexPartial(string SelectedIds) {
List<int> myData = System.Web.Helpers.Json.Decode<List<int>>(myComplexData);
...
}