Q3 2011 Grid - setting page size options

3 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.

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

    C#:
    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.Clear();
               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;
           }
       }

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


    Thanks,
    Princy

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Eon
    Eon avatar
    15 posts
    Member since:
    Apr 2015

    Posted 05 Jan in reply to Princy Link to this post

    Thanks your aspx solution worked for me.
Back to Top