Anna L
Anna L

Reputation: 122

How set page number 2 of paging in table on start

I try manually set start page of MudTable by using NavigateTo, but get no result.

protected override async Task OnAfterRenderAsync(bool firstRender){
   await base.OnAfterRenderAsync(firstRender).ConfigureAwait(true);
   if(firstRender){
     table.NavigateTo(2);
    }
}

Reproduction link https://try.mudblazor.com/snippet/GkQbvkvcxNzoxxaq

Upvotes: 1

Views: 1676

Answers (1)

New Rhino
New Rhino

Reputation: 339

You can set this directly in your MudTable element :

<MudTable CurrentPage="2">

If you do this remove the lines you added in OnAfterRenderAsync.

You can find this in the API doc.

Also changing this :

table.NavigateTo(2);

To this :

table.CurrentPage = 2;

Seems to be working too, but setting it in the elements seems cleaner.

Upvotes: 1

Related Questions