BootstrapGridViewBuilderBase<T>.Routes(Action<GridViewRouteCollectionBuilder>) Method
Specifies a collection of routes for Grid View‘s updates or performing other Controller-side operations on demand.
Namespace: DevExpress.AspNetCore.Bootstrap
Assembly:
DevExpress.AspNetCore.Bootstrap.v18.2.dll
Declaration
public T Routes(
Action<GridViewRouteCollectionBuilder> config
)
Public Function Routes(
config As Action(Of GridViewRouteCollectionBuilder)
) As T
Parameters
Returns
Type |
Description |
T |
A reference to this instance after the operation is completed.
|
IMPORTANT
Bootstrap Controls for ASP.NET Core are in maintenance mode. We don’t add new controls or develop new functionality for this product line. Our recommendation is to use the ASP.NET Core Controls suite.
$1
Grid View provides you with three main routing types:
- updating the control markup;
- implementing the CRUD (create, update and delete) functionality;
- implementing a custom server-side logic.
The example below demonstrates how to implement a custom server-side logic using the Routes method.
@(Html.DevExpress()
.BootstrapButton("groupByCountryButton")
.Text("Group by Country column")
.ClientSideEvents(events => events.Click("onGroupByCountryButtonClick")))
@Html.Partial("GridViewPartial", Model)
@model IEnumerable
@(Html.DevExpress()
.BootstrapGridView<Customer>("gridView")
.Routes(routes => routes
.MapRoute(route => route
.Controller("GridView")
.Action("GridViewPartial"))
.MapRoute(route => route
.RouteType(GridViewRouteType.Custom)
.Controller("GridView")
.Action("GroupBy")))
.Settings(settings => settings.ShowGroupPanel(true))
.Columns(columns => {
columns.Add(m => m.ContactName);
columns.Add(m => m.CompanyName);
columns.Add(m => m.Country).GroupIndex(1);
columns.Add(m => m.City);
columns.Add(m => m.Region);
})
.Bind(Model))
using System;
using DevExpress.AspNetCore.DemoModels;
using Microsoft.AspNetCore.Mvc;
namespace DevExpress.AspNetCore.Demos {
public class GridViewController : Controller {
public GridViewController(IDevExpressControlAccessor devExpress, NorthwindContext northwindContext){
DevExpress = devExpress;
NorthwindContext = northwindContext;
}
protected IDevExpressControlAccessor DevExpress { get; }
protected NorthwindContext NorthwindContext { get; }
public IActionResult Index() {
return View(NorthwindContext.Customers);
}
public IActionResult GridViewPartial() {
return PartialView(NorthwindContext.Customers);
}
public IActionResult GroupBy() {
var grid = DevExpress.GridView("GridViewPartial", NorthwindContext.Customers);
grid.ClearSort();
grid.DataColumns["Country"].GroupBy();
grid.ExpandAll();
return grid.GetActionResult();
}
}
}
function onGroupByCountryButtonClick(args) {
grid.performCallback();
}
See Also