This is a migrated thread and some comments may be shown as answers.

How to persist page size?

4 Answers 196 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 14 Jan 2019, 10:47 PM

 

How do you persist the PageSize combo setting if the user refreshes the page? It seems to always revert to 25.

 

            <telerik:RadGrid ID="RadGrid1" runat="server"
                OnItemCommand="RadGrid1_ItemCommand"
                RenderMode="Lightweight"
                OnNeedDataSource="RadGrid1_NeedDataSource"
                AllowPaging="True"
                PageSize="25"
                AllowSorting="True"
                CellSpacing="-1"
                GridLines="Both"
                >
                <MasterTableView AutoGenerateColumns="true" TableLayout="Fixed" DataKeyNames="Catalog #">
                    <NestedViewTemplate>
                        <div>
                            <div style="float: left;">
                                <%
                                    int catalogId = Convert.ToInt32(RadGrid1.SelectedValue);

                                    List<string> files = GetImageUrlList(catalogId);
                                    if (files != null)
                                    {
                                        foreach (var path in files)
                                        { %>
                                            <img src='<%= path %>' height="400px" />
                                <%      }  
                                    } %>
                            </div>
                            <div style="clear: both">
                            </div>
                        </div>
                    </NestedViewTemplate>
                    <PagerStyle PageSizes="25,50,100" PagerTextFormat="{4}<strong>{5}</strong> rows"
                        PageSizeLabelText="Rows per page:" />
                </MasterTableView>
                <GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
                <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
                    <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" />
                    <Scrolling AllowScroll="true" ScrollHeight="" UseStaticHeaders="true" />
                </ClientSettings>
                <FilterMenu RenderMode="Lightweight"></FilterMenu>
                <HeaderContextMenu RenderMode="Lightweight"></HeaderContextMenu>
            </telerik:RadGrid>

 

 

4 Answers, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 17 Jan 2019, 05:54 PM
Hi Paul,

There is a Knowledge Base article describing the steps to persist the current page index. See Persist current PageIndex or stay with the first item after PageSize changed in RadGrid 

I hope this will prove helpful.

Kind regards,
Attila Antal
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Paul
Top achievements
Rank 1
answered on 17 Jan 2019, 07:13 PM

This question is about PageSize! There is nothing in that article that persists PageSize. It doesn't work.

I've tried a few things but I think I don't have enough information on the grid and the page lifecycle.

0
Paul
Top achievements
Rank 1
answered on 17 Jan 2019, 07:17 PM

 

I think I fixed it by altering your demo as follows:

 

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OldPageIndex = RadGrid1.CurrentPageIndex;
                //OldPageSize = RadGrid1.PageSize;
                RadGrid1.PageSize = OldPageSize;
            }
        }

 

 

0
Attila Antal
Telerik team
answered on 18 Jan 2019, 07:39 AM
Hi Paul,

I apologize, I have missed out to say that you could take a look at the sample from the article and follow the same concept for the PageSize. Our controls can be configured in many different ways, but we only have demos, examples and documentation for the most common scenarios.

I hope you've managed to achieve the described behavior. In case something didn't go as planned, let us know. We'll help you out.

Kind regards,
Attila Antal
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Paul
Top achievements
Rank 1
Share this question
or