We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How I can go to the last page of the grid and to the last row of the Datasource

Hi,

I would like to know

How I can go to the last page of the grid and to the last row of the Datasource  in a Blazor grid


Thank you



1 Reply 1 reply marked as answer

MS Monisha Saravanan Syncfusion Team October 20, 2022 12:04 PM UTC

Hi Nick,


Greetings from Syncfusion support.


Query: “How I can go to the last page of the grid and to the last row of the Datasource  in a Blazor grid”


We have checked your query and prepared an sample as per your shared reference. Here we have calculated programmatically to navigate to the last page of the Grid and to select the last record using GoToPage method and SelectRowsAsync method. Kindly check the below code snippet and sample for your reference.


 

<SfButton @onclick="click">Select last Record</SfButton>

 

 

<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true">

    <GridPageSettings PageSize="8"></GridPageSettings>

    <GridColumns>

    </GridColumns>

</SfGrid>

 

@code{

    public List<Order> Orders { get; set; }

    public SfGrid<Order> Grid { get; set; }

    public async Task click()

    {

        // To select the last page

        double count = Orders.Count();

        decimal pagesize = Grid.PageSettings.PageSize;

        var TotalRec = Grid.DataSource.Count();

        double Totalpage =(double) Math.Ceiling(TotalRec/pagesize );

        var a = Grid.PageSettings.PageCount;

        await Grid.GoToPageAsync(Totalpage);

 

        // To select the last record

         var CurrentView = Grid.GetCurrentViewRecordsAsync();

        var Coun = (CurrentView.Result.Count)-1;

        var data = CurrentView.Result[Coun];

        var val = Grid.GetRowIndexByPrimaryKeyAsync(data.OrderID);

        double value = Convert.ToDouble(val.Result);

        await Grid.SelectRowAsync(value);

      

 

    }

  

 

}


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorApp1886629039.zip


Please let us know if you have any concerns.


Regards,

Monisha

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.



Marked as answer
Loader.
Live Chat Icon For mobile
Up arrow icon