Search results

How to show grouped rows based on the pageSize in ASP.NET MVC Grid control

By default, we have displayed the no of records based on the PageSize. If you want to show grouped column rows based on the PageSize then we suggest you to use the below way.

In the below sample, we have overridden the default generateQuery to display the grouped rows instead of grid rows based on the PageSize.

    var old = ej.grids.Data.prototype.generateQuery;
    ej.grids.Data.prototype.generateQuery = function () {
        var query =, true);
        return query;

@Html.EJS().Grid("FlatGrid").DataSource((IEnumerable<object>)ViewBag.DataSource).AllowSorting().Columns(col =>
   col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
   col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add();
   col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add();

}).AllowPaging().PageSettings(page => page.PageSize(5)).AllowGrouping().GroupSettings(group=>group.Columns(new string[] { "ShipCountry" })).Render()
public IActionResult Index()
    var Order = OrderDetails.GetAllRecords();
    ViewBag.DataSource = Order;
    return View();