Unplanned
Last Updated: 12 Jul 2022 06:51 by ADMIN
SaiSivaSankar
Created on: 09 Sep 2020 14:20
Category: Grid
Type: Feature Request
11
Sticky (locked) group header
I would like to exclude the group header from the horizontal scroll - that is, the group header must always be visible regardless of how the user scrolls the grid left and right, like a Locked column.
1 comment
ADMIN
Dimo
Posted on: 12 Jul 2022 06:51

Hi all,

In case anyone is interested, here is how to stick group headers during vertical scrolling. The suggestion works for one grouping level.

<TelerikGrid Data="@GridData"
             TItem="@Employee"
             Pageable="true"
             PageSize="30"
             Sortable="true"
             Groupable="true"
             Height="600px">
    <GridColumns>
        <GridColumn Field=@nameof(Employee.Name) />
        <GridColumn Field=@nameof(Employee.Team) />
        <GridColumn Field=@nameof(Employee.Salary) />
        <GridColumn Field=@nameof(Employee.OnVacation) />
    </GridColumns>
</TelerikGrid>

<style>
    .k-grid .k-grouping-row {
        position: static;
        z-index: auto;
        top: 0;
    }

    .k-grid .k-grouping-row td {
        position: sticky;
        z-index: 2;
        top: inherit;
        bottom: inherit;
    }

</style>

@code {
    List<Employee> GridData { get; set; }

    protected override void OnInitialized()
    {
        GridData = new List<Employee>();
        var rnd = new Random();

        for (int i = 1; i <= 100; i++)
        {
            GridData.Add(new Employee()
            {
                Id = i,
                Name = "Name " + i,
                Team = "Team " + (i % 11 + 1),
                Salary = (decimal)rnd.Next(1000, 3000),
                OnVacation = i % 3 == 0
            });
        }
    }

    public class Employee
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Team { get; set; }
        public decimal Salary { get; set; }
        public bool OnVacation { get; set; }
    }
}

 

Regards,
Dimo
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.