|
@page "/"
@page "/{CurrentPage:int}"
@inject NavigationManager Navigate
@using Syncfusion.Blazor
@using Syncfusion.Blazor.Data
@using Syncfusion.Blazor.Grids
@using BlazorApp1.Data
<SfGrid TValue="Orders" AllowPaging="true">
<GridEvents OnActionBegin="ActionBegin" TValue="Orders"></GridEvents>
<GridPageSettings CurrentPage="@CurrentPage"></GridPageSettings>
<SfDataManager Url="api/Values" Adaptor="Adaptors.WebApiAdaptor"></SfDataManager>
. . .. . . .
</SfGrid>
@code{
public void ActionBegin(ActionEventArgs<Orders> Args)
{
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Paging)
{
Args.Cancel = true; // prevent the default action.
Navigate.NavigateTo($"/{Args.CurrentPage}"); // navigate to required page.
}
}
private int _page = 1;
[Parameter]
public int CurrentPage
{
get { return _page; }
set { _page = value == 0 ? 1 : value; }
}
}
|
If I do Args.Cancel=true to prevent default action. Then PageSizes selection does not work and shows negative values.
Why is this? and why do we need to prevent the default action when using QueryString?