Is it possible that it doesn't save the GridPageSettings value when EnablePersistence is active?

I want to use EnablePersistence feature in Grids but I want to disable GridPageSettings feature, is it possible?

There are other reasons, but the most important reason is that I want to automatically adjust the number of pages of the grid according to the screen size as in the example below, but each time it paginates according to the previously saved value.

https://www.syncfusion.com/forums/155926/how-to-set-full-page-height-for-grid-with-paging-enabled


3 Replies

MS Monisha Saravanan Syncfusion Team February 4, 2022 05:43 AM UTC

Hi Seckin, 

Greetings from Syncfusion support. 

In this forum, we have provided solution to change the pagesize in OnAfterRender lifecycle method of Grid. Hence the reported behavior occurred when enabling the persistence in Grid. We suggest you to achieve your requirement by handling page size on the Databound event. So that the grid will rendered with new page size for each time when we refresh the browser.  

Kindly check the attached code snippet and sample for your reference. 

<SfGrid ID="page4" @ref="Grid" DataSource="@Orders" EnablePersistence="true" AllowPaging="true"> 
   <GridEvents DataBound= "Databound" TValue="Order"></GridEvents> 
    <GridColumns> 
... 
    </GridColumns> 
</SfGrid> 
 
@code{ 
public bool FirstRender = true; 
    public async Task Databound() 
    { 
        if (FirstRender) 
        { 
            var dimension = await Service.GetDimensions(); 
            var visina = dimension.Height - 170; 
            (this.Grid.PageSettings as GridPageSettings).PageSize = visina / 37; 
            FirstRender = false; 
            Grid.Refresh(); 
        } 
    } 


Kindly get back to us if we misunderstood your query or if you have further queries. 

Regards, 
Monisha 



SK Seckin Karabacakoglu February 4, 2022 06:17 AM UTC

Hi Monisha 

It worked exactly as I wanted. Thank you so much.

Regards



MS Monisha Saravanan Syncfusion Team February 7, 2022 04:14 AM UTC

Hi Seckin, 

Thanks for the update. 

We are glad to hear that your query has been resolved. Please get back to us if you need further assistance. 

Regards, 
Monisha  


Loader.
Up arrow icon