Q3 2011 Grid - setting page size options

5 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    14 posts
    Member since:
    Feb 2011

    Posted 22 Jun 2013 Link to this post

    We know we have set what the available page size options were on a Radgrid before, but we can't find our code for it. 2012 version had a Pagesizes property, but that's not there on Q3 2011. Anyone remember what the correct way to control page sizes in Q3 2011 was?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Jun 2013 Link to this post

    Hi Jonathan,

    You can set the page size in the client side as follows.

    <telerik:RadGrid  ID="RadGrid1"   AllowPaging="true"  runat="server" PageSize="50">          
          <MasterTableView >
               <PagerStyle Mode="NextPrevAndNumeric" PageSizeLabelText="Page Size: " PageSizes="5,10,25,50,100,250" />
                   . . . . . . . . .
                   . . . . . . . . .
    OR you can pro-grammatically set it in the server side as follows.

    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
           if (e.Item is GridPagerItem)
               RadComboBox PageSizeCombo = (RadComboBox)e.Item.FindControl("PageSizeComboBox");
               PageSizeCombo.Items.Add(new RadComboBoxItem("10"));
               PageSizeCombo.FindItemByText("10").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);
               PageSizeCombo.Items.Add(new RadComboBoxItem("20"));
               PageSizeCombo.FindItemByText("20").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);
               PageSizeCombo.Items.Add(new RadComboBoxItem("50"));
               PageSizeCombo.FindItemByText("50").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);
               PageSizeCombo.Items.Add(new RadComboBoxItem("100"));
               PageSizeCombo.FindItemByText("100").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);
               PageSizeCombo.Items.Add(new RadComboBoxItem("200"));
               PageSizeCombo.FindItemByText("200").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);
               PageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;

    <telerik:RadGrid ID="RadGrid1"  AllowPaging="True" PageSize="50" runat="server" OnItemDataBound="RadGrid1_ItemDataBound">
        <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>


  3. Eon
    Eon avatar
    15 posts
    Member since:
    Apr 2015

    Posted 05 Jan 2016 in reply to Princy Link to this post

    Thanks your aspx solution worked for me.
  4. Jimmy
    Jimmy avatar
    9 posts
    Member since:
    May 2017

    Posted 22 Jan 2018 Link to this post

    Whenever I try to set the PageSize to something other than the default size in the grid the combobox values change but the number of items in the grid stays at the default.  

    In my case my default page size is set to 25 but I want to change the grid to display 50 items and set the combo to 50.


    See Below:

            protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
                if (e.Item is GridPagerItem)
                    RadComboBox PageSizeCombo = (RadComboBox)e.Item.FindControl("PageSizeComboBox");
                    PageSizeCombo.Items.Add(new RadComboBoxItem("25"));
                    PageSizeCombo.FindItemByText("25").Attributes.Add("ownerTableViewId", RadGrid2.MasterTableView.ClientID);
                    PageSizeCombo.Items.Add(new RadComboBoxItem("50"));
                    PageSizeCombo.FindItemByText("50").Attributes.Add("ownerTableViewId", RadGrid2.MasterTableView.ClientID);
                    PageSizeCombo.Items.Add(new RadComboBoxItem("100"));
                    PageSizeCombo.FindItemByText("100").Attributes.Add("ownerTableViewId", RadGrid2.MasterTableView.ClientID);
                    PageSizeCombo.Items.Add(new RadComboBoxItem("200"));
                    PageSizeCombo.FindItemByText("200").Attributes.Add("ownerTableViewId", RadGrid2.MasterTableView.ClientID);
                    PageSizeCombo.Items.Add(new RadComboBoxItem("500"));
                    PageSizeCombo.FindItemByText("500").Attributes.Add("ownerTableViewId", RadGrid2.MasterTableView.ClientID);
                    int nSelectedIndex = 50;
                    e.Item.OwnerTableView.PageSize = 50;
                    switch (nSelectedIndex)
                        case 1:
                            PageSizeCombo.FindItemByText("50").Selected = true;
                            e.Item.OwnerTableView.PageSize = 50;
                        case 2:
                            PageSizeCombo.FindItemByText("100").Selected = true;
                            e.Item.OwnerTableView.PageSize = 100;
                        case 3:
                            PageSizeCombo.FindItemByText("200").Selected = true;
                            e.Item.OwnerTableView.PageSize = 200;
                        case 4:
                            PageSizeCombo.FindItemByText("300").Selected = true;
                            e.Item.OwnerTableView.PageSize = 300;

                            PageSizeCombo.FindItemByText("25").Selected = true;
                            e.Item.OwnerTableView.PageSize = 25;


                <telerik:RadGrid ID="RadGrid2" runat="server" AllowFilteringByColumn="true"  AllowAutomaticDeletes="True" AllowSorting="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True" AutoGenerateColumns="False" ClientSettings-Resizing-AllowColumnResize="true" DataSourceID="SqlDataSource2" GridLines="Both" OnPreRender="RadGrid2_PreRender" PageSize="20" Skin="Office2007"  ShowFooter="true"  OnItemDataBound="RadGrid2_ItemDataBound">
                        <ClientEvents OnBatchEditCellValueChanged="ValueChangedRadGrid2" OnRowDeleted="OnDelete" OnCommand="OnCommand"/>
                    <MasterTableView AutoGenerateColumns="False"  PageSize="25" CommandItemDisplay="Top" DataKeyNames="ID" EditMode="Batch" HorizontalAlign="NotSet" AllowMultiColumnSorting="False" AllowSorting="true">

  5. Eyup
    Eyup avatar
    3962 posts

    Posted 25 Jan 2018 Link to this post

    Hello Jimmy,

    This functionality is provided built-in by RadGrid - please use the PageSizes property to achieve this requirement:

    This will resolve the selection issue of the correct combo item.

    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top