Declined
Last Updated: 09 Sep 2020 16:26 by ADMIN
Cory
Created on: 08 Sep 2020 15:58
Category: Grid
Type: Bug Report
1
Inline update on grid with on edit handler causes grid to reset if editing last item on any page but the first

Hello,

When using grid command button edit with the onedit handler shown in this documentation https://docs.telerik.com/blazor-ui/components/grid/editing/inline

There is a bug that causes the grid to reset to the first page when editing the last item on any page that isn't the first. In other words we can edit the last item in the gird on the first page but not on the second, third, fourth...etc. 
I have taken out all the logic in my edit handler as well and the problem still presents itself. 

Below is the relevenat code sample and I have also zipped a short video demonstrating the behavior.

<TelerikGrid @ref="@GridNameHere"
                             Class="smallerFont"
                             Data="@DataHere"
                             Pageable="true"
                             Page="@Page"
                             PageSize="@PageSize"
                             TotalCount="@Total"
                             Sortable="@true"
                             Groupable="@false"
                             FilterMode="@GridFilterMode.FilterMenu"
                             Reorderable="@true"
                             OnEdit="@OnEdit"
                             OnUpdate="@OnUpdate"
                             OnCreate="@OnUpdate">
                    <GridToolBar>
                        <GridCommandButton Command="Add" Icon="add">Add</GridCommandButton>
                    </GridToolBar>
                    <GridColumns>
                        <GridCommandColumn Width="150px">
                            <GridCommandButton Command="Edit" Icon="edit">Edit</GridCommandButton>
                            <GridCommandButton Command="Save" Icon="save" ShowInEdit="true">Save</GridCommandButton>
                            <GridCommandButton Command="Cancel" Icon="cancel" ShowInEdit="true">Cancel</GridCommandButton>
                        </GridCommandColumn>

                        <GridColumn Field="@(nameof(ModelName.FieldName))" Title="Column Name" Width="100px" />

                    </GridColumns>
                </TelerikGrid>

//Handler for edit

 protected void OnEdit(GridCommandEventArgs args)
{

// no code in here and problem still presents itself but feel free to put anything I recommend using the sample from the documentation above

}

Attached Files:
1 comment
ADMIN
Marin Bratanov
Posted on: 09 Sep 2020 16:26

Hello Cory,

I am attaching here a working sample you can compare against.

The issue in the provided snippet is that the Page parameter is bound only one-way to a variable, so when the grid re-renders, it takes that value for its page and that defaults to 1. Since two-way binding is not used (the @bind-Page syntax, or the PageChanged event to update the view-model), this parameter value remains wrong. I also added notes in the docs about this framework behavior.

 

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.