# OData Group Lazy-Loading

## Content

The `ODataCollectionView` supports group lazy loading to improve performance when working with large datasets. With group lazy loading enabled, the collection initially loads only top-level groups and retrieves child records when a group is expanded.
This approach helps:

* Reduce the initial data load
* Improve rendering performance
* Optimize data retrieval for large grouped datasets

## **Configure Group Lazy Loading**

To enable group lazy loading:

* Set the `groupOnServer` property to `true`
* Set the `groupLazyLoading` property to `true`
* Define one or more `GroupDescription` objects

This example demonstrates how to enable `groupLazyLoading`.

```auto
@(Html.C1().FlexGrid()
    .Id("ODataGroupLazyLoading")
    .CssStyle("height", "400px")
    .IsReadOnly(true)
    .BindODataSource(odsb =>
                        odsb.ServiceUrl("https://demodata.mescius.io/adventureworks/odata/v1/")
                        .TableName("SalesOrderHeaders")
                        .GroupOnServer(true)
                        .GroupLazyLoading(true)
                        .GroupDescriptions(new C1.Web.Mvc.GroupDescription[]
                        {
                            new C1.Web.Mvc.PropertyGroupDescription()
                            {
                                PropertyName = "AccountNumber"
                            }
                        })
                        .SortOnServer(Convert.ToBoolean(optionsModel.Options["Sort On Server"].CurrentValue))
                        .FilterOnServer(Convert.ToBoolean(optionsModel.Options["Filter On Server"].CurrentValue))

    )
    .Columns(bl =>
    {
        bl.Add(cb => cb.Binding("AccountNumber").Header("Account Number").Visible(false));
        bl.Add(cb => cb.Binding("PurchaseOrderNumber").Header("Purchase Order Number"));
        bl.Add(cb => cb.Binding("SalesOrderNumber").Header("Sales Order Number"));
        bl.Add(cb => cb.Binding("SubTotal").Header("Sub Total"));
        bl.Add(cb => cb.Binding("TaxAmt").Header("Tax Amount"));
        bl.Add(cb => cb.Binding("Freight").Header("Freight"));
        bl.Add(cb => cb.Binding("TotalDue").Header("Total Due"));
        bl.Add(cb => cb.Binding("ModifiedDate").Header("Modified Date"));
    })
    .Filterable(fb => fb.DefaultFilterType(FilterType.Both))
    .OnClientLoadedRows("oDataGroupLazyLoadingLoaded")
)
```