Grid not resetting to last populated page when removing items

Hello @Team.

The problem is that my grid operations are executed on an inherited component, so StateHasChanged doesn't work. I am using the Grid.Reload() function to update the grid data when removing, editing and adding items. However this method doesn't update the page to the last populated. Any workarounds?

This will reload (rerender) the DataGrid according to the value provided as Data. Check the variable bound to Data property.

Here is the code from the .gif in the OP.

Component:

@inherits BaseList<AccessPoint>
...
<RadzenGrid @ref=@(Grid) Data=@(FilteredItems)/>

Inherited component (BaseList):

protected RadzenGrid<T> Grid;
protected T[] FilteredItems = Array.Empty<T>();
...
protected async Task RemoveData(T item)
{
    var type = typeof(T);
    var propertyInfo = type.GetProperty($"{type.Name}Id");
    for (int i = Array.FindIndex(FilteredItems, x => propertyInfo.GetValue(x).Equals(propertyInfo.GetValue(item))); i < FilteredItems.Length - 1; i++)
    {
        FilteredItems[i] = FilteredItems[i + 1];
    }
    Array.Resize(ref FilteredItems, FilteredItems.Length - 1);
    await Grid.Reload();
}

Debugging:

Radzen.Blazor 3.5.3

I tried your code in our InLine edit demo and it worked normally:

I think my problem has been misunderstood. Try removing all the items from the last page. The page now has zero items and thus the grid should automatically move to the page before this one, but it soft locks. The bug is reproduceable in the same demo you've shown me:

Thanks! We will check the behavior. In the meantime you can execute LastPage() instead Reload().

1 Like