How to persist page size?

5 posts, 0 answers
  1. Paul
    Paul avatar
    13 posts
    Member since:
    Nov 2014

    Posted 14 Jan Link to this post

     

    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>

     

     

  2. Attila Antal
    Admin
    Attila Antal avatar
    204 posts

    Posted 17 Jan Link to this post

    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.
  3. Paul
    Paul avatar
    13 posts
    Member since:
    Nov 2014

    Posted 17 Jan in reply to Attila Antal Link to this post

    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.

  4. Paul
    Paul avatar
    13 posts
    Member since:
    Nov 2014

    Posted 17 Jan in reply to Paul Link to this post

     

    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;
                }
            }

     

     

  5. Attila Antal
    Admin
    Attila Antal avatar
    204 posts

    Posted 18 Jan Link to this post

    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.
Back to Top