How to set Page Size in sfgrid based on screen resolution

I have an sfgrid in blazor web application. I would like to know how to set Page Size in sfgrid based on screen resolution for example 

If I have 1027 X 768 resolution then Page size is 10

If I have 1366 X 768 resolution then Page size is 15


1 Reply

SP Sarveswaran Palani Syncfusion Team September 28, 2023 05:23 PM UTC

Hi Kins,

Greetings from Syncfusion support.

From your query, we suspect that you want to set page size dynamically based on the browser layout. Based on your requirement, we prepared sample using Media Query component based on that we’ll render grid pager size accordingly. We have attached the code snippet and sample for your reference.

<SfMediaQuery @bind-ActiveBreakpoint="@activeBreakpoint"></SfMediaQuery>

@if (activeBreakpoint == "Medium")

{

    pagesize = 10;

}

else

{

    pagesize = 15;

}

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

    <GridPageSettings PageSize="@pagesize"></GridPageSettings>

@code {

    private string activeBreakpoint;

 

    public int pagesize { get; set; } = 10;

 

    protected override void OnInitialized()

    {

        SfMediaQuery.Small.MediaQuery = "(max-width: 500px)";

        SfMediaQuery.Medium.MediaQuery = "(max-width: 1027px)";

        SfMediaQuery.Large.MediaQuery = "(min-width: 1366px)";

        base.OnInitialized();

    }
}


If you have any further queries, please get back to us.

Regards,
Sarvesh


Attachment: BlazorAppPaging_204bfe02.zip

Loader.
Up arrow icon