Grid always comeback to first page

Hello,
I have got DataGrid in my Blazor C# Project.
And I have got a problem with navigation.

For example. I have got 5 pages with data, presented on DataGrid
When I'm on 2nd page and press "details" button for example to see more data and navigate back I'm again on the first page, not the 2nd. Is there any way to fix that? It's really annoying for many customers.

Best regards

Any additional info how to reproduce this?

Hello!

Like I said - I've got a page with warehouse transactions presented on DataGrid.
The're is about 8 pages with this data, of course I can navigate between them.

And now:
I on the 6th page of my DataGrid -> I press the specific row to navigate to the details of this transaction -> pressing return button -> And my grid is on the first page, not the 6th when i started to check the details. And now I need to again navigate to the 6th page.

This information is not enough to reproduce the problem, check our forum FAQ for reference how to improve your question. If you have Radzen subscription you can send us an example application at info@radzen.com where we can reproduce the issue.

Rob did you ever solve this issue? I have exactly the same problem and don't know how i could explain any better than you did

I was able to figure it out, clicking a button somehow forces the grid to reload data from data context. and when data context changes, datagrid goes back to first page.

As I do not know how your code looks, I assume that you are not using dialog. To stay on record that you are viewing you need to use dialog not a simple page.

Hi,
I am adding a new row with this code and it goes to the first page. How can I make it stay and row still expanded?

private async Task OnCreateRowDetail(OrderDetailDto? orderDetail)
{
    if (orderDetail != null)
    {
        orderDetailMap = new OrderDetail();
        Mapper.Map(orderDetail, orderDetailMap);

        // Add the new order detail to the database
        var addedOrderDetail = await AddOrderDetailUseCase.ExecuteAsync(orderDetailMap);

        Mapper.Map(addedOrderDetail, orderDetail);
        // Find the parent order
        var parentOrder = GetParentOrder(orderDetail);

        if (parentOrder != null)
        {
            _order = ViewOrdersUseCase.Execute(user);
            _ordersDto = Mapper.ProjectTo<OrderDto>(_order);
            
            await _grid!.ExpandRow(parentOrder);
        }
               
    }
}
protected async override Task OnAfterRenderAsync(bool firstRender)
{
    if (!firstRender) {

      await grid.GoToPage(currnetPage, true);

    }
}

I have master-detail data grids. How can I keep the row expanded after adding a new row to the detail?

@Ali_Omoum @msalman @Djordje
I managed to stay at the current page after adding a new row to the detail grid but still struggling how to keep the row expanded.

protected override void OnAfterRender(bool firstRender)
{
    if (firstRender)
    {
        _grid.SettingsChanged = new EventCallback<DataGridSettings>(this, async (DataGridSettings settings) =>
        {
            current_page = settings.CurrentPage;
        });
    }
    base.OnAfterRender(firstRender);
}

// Add a method to find the parent OrderDto of a given OrderDetailDto
private OrderDto? GetParentOrder(OrderDetailDto detail)
{
    return _ordersDto.FirstOrDefault(o => o.Id == detail.OrderId);
}

private async Task OnCreateRowDetail(OrderDetailDto? orderDetail)
{
    if (orderDetail != null)
    {
        orderDetailMap = new OrderDetail();
        Mapper.Map(orderDetail, orderDetailMap);

        // Add the new order detail to the database
        var addedOrderDetail = await AddOrderDetailUseCase.ExecuteAsync(orderDetailMap);

        Mapper.Map(addedOrderDetail, orderDetail);
        // Find the parent order
        var parentOrder = GetParentOrder(orderDetail);

        if (parentOrder != null)
        {
            _order = ViewOrdersUseCase.Execute(user);
            _ordersDto = Mapper.ProjectTo<OrderDto>(_order);

            pageIndex = current_page;
            await _grid.GoToPage((int)pageIndex);
            await _grid.ExpandRow(parentOrder);
           
            StateHasChanged();

        }
        
    }
}