Completed
Last Updated: 24 Sep 2020 09:44 by ADMIN
Release 2.18.0
Andrew
Created on: 14 Jul 2020 19:20
Category: Grid
Type: Bug Report
8
Pressing Down arrow at the end of a grid with Pageable=false and Navigable=true throws a NullReferenceException

Reproducible:

 

1. Run the snippet below
2. click the grid
3. press Down until you reach the last row, then press Down again

 

<TelerikGrid Navigable="true" Pageable="false"
             Data=@GridData Height="400px" >
    <GridColumns>
        <GridColumn Field=@nameof(Employee.Name) />
        <GridColumn Field=@nameof(Employee.Team) Title="Team" />
    </GridColumns>
</TelerikGrid>

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

    protected override void OnInitialized()
    {
        GridData = new List<Employee>();
        for (int i = 0; i < 15; i++)
        {
            GridData.Add(new Employee()
            {
                EmployeeId = i,
                Name = "Employee " + i.ToString(),
                Team = "Team " + i % 3
            });
        }
    }

    public class Employee
    {
        public int EmployeeId { get; set; }
        public string Name { get; set; }
        public string Team { get; set; }
    }
}
1 comment
ADMIN
Marin Bratanov
Posted on: 30 Jul 2020 16:50

A possible workaround for a regular grid (fewer items, Scrollable, not for virtual scrolling) is enabling a pager whose page size equals the number of items in the data, and hiding it visually

<style>
    .no-pager .k-pager-wrap {
        display: none;
    }
</style>

<TelerikGrid Navigable="true" Pageable="true" PageSize="@GetItemsCount()"
             Data=@GridData Height="400px" Class="no-pager">
    <GridColumns>
        <GridColumn Field=@nameof(Employee.Name) />
        <GridColumn Field=@nameof(Employee.Team) Title="Team" />
    </GridColumns>
</TelerikGrid>

@code {
    public List<Employee> GridData { get; set; }
    int GetItemsCount()
    {
        if(GridData != null)
        {
            return GridData.Count();
        }
        return 1;
    }

    protected override void OnInitialized()
    {
        GridData = new List<Employee>();
        for (int i = 0; i < 15; i++)
        {
            GridData.Add(new Employee()
            {
                EmployeeId = i,
                Name = "Employee " + i.ToString(),
                Team = "Team " + i % 3
            });
        }
    }

    public class Employee
    {
        public int EmployeeId { get; set; }
        public string Name { get; set; }
        public string Team { get; set; }
    }
}

 

 

Regards,
Marin Bratanov
Progress Telerik