Search results

Collapse all grouped rows at initial rendering in ASP.NET Core Grid control

20 Oct 2021 / 1 minute to read

You can collapse all the grouped rows at initial rendering by using dataBound event with collapseAll method of the grid.

In the below demo, all the grouped rows are collapsed at initial rendering.

Copied to clipboard
<ejs-grid id="Grid" dataSource="@ViewBag.DataSource" allowGrouping="true" dataBound="bound">
<e-grid-groupsettings columns="@(new string[] {"ShipCountry"})"></e-grid-groupsettings>
        <e-grid-column field="OrderID"  headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="100"></e-grid-column>                
        <e-grid-column field="CustomerID" headerText="Customer ID" type="string" width="120"></e-grid-column>                
        <e-grid-column field="Freight" headerText="Freight" textAlign="Right" format="C2" editType="numericedit" width="120"></e-grid-column>                               
        <e-grid-column field="ShipCountry" headerText="Ship Country" width="150" editType='dropdownedit'></e-grid-column>                

    var initial = true;
    function bound() {
        if (initial === true) {
            initial = false;
Copied to clipboard
public IActionResult Index()
    ViewBag.DataSource = OrderDetails.GetAllRecords();
    return View();