Changing RadGrid PageSize Dropdown

10 posts, 0 answers
  1. Joshua
    Joshua avatar
    1 posts
    Member since:
    May 2008

    Posted 22 Feb 2010 Link to this post

    I'm just looking to add a few options to the drop down list of, make it 15,50,150,250. There's got to be an easy way to do this yes? I don't want to change anything else on paging, but I have a feeling I need to change the pager template? Is there a template I can use that is exactly the same but I can update the drop down? Wish there was a need date source for that drop down. Any ideas would be great, thanks.

    Joshua
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Feb 2010 Link to this post

    Hello Joshua,

    The following code shows how to customize the PageSize combobox to show required options. Hope this helps.

    C#:
     
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)   
    {   
        if (e.Item is GridPagerItem)   
        {   
            RadComboBox PageSizeCombo = (RadComboBox)e.Item.FindControl("PageSizeComboBox");   
      
            PageSizeCombo.Items.Clear();   
            PageSizeCombo.Items.Add(new RadComboBoxItem("15"));   
            PageSizeCombo.FindItemByText("15").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("150"));   
            PageSizeCombo.FindItemByText("150").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);   
            PageSizeCombo.Items.Add(new RadComboBoxItem("250"));   
            PageSizeCombo.FindItemByText("250").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);   
            PageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true
        } 

    Best wishes,
    Shinu.
  3. lina fetisova
    lina fetisova avatar
    110 posts
    Member since:
    Apr 2010

    Posted 26 Jan 2011 Link to this post

    Shinu, thank you very much!
  4. Swaroop
    Swaroop avatar
    3 posts
    Member since:
    Mar 2011

    Posted 04 Mar 2011 Link to this post

    Can i able to Put option "All" in Pager dropdown so that to display all the items at a time?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Mar 2011 Link to this post

    Hello Swaroop,

    Try the following code snippet to achieve your requirement.
    C#:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
        if (e.Item is  GridPagerItem)
            {
                GridPagerItem pager = (GridPagerItem)e.Item;
                RadComboBox PageSizeComboBox = (RadComboBox)pager.FindControl("PageSizeComboBox");
                RadComboBoxItem ComboItem = new RadComboBoxItem("All");
                PageSizeComboBox.Items.Insert(0, ComboItem);
                PageSizeComboBox.AutoPostBack = true;
                PageSizeComboBox.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(PageSizeComboBox_SelectedIndexChanged);
            }
        }
    void PageSizeComboBox_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
       {
           //Handle the event
       }

    Thanks,
    Shinu.
  6. Swaroop
    Swaroop avatar
    3 posts
    Member since:
    Mar 2011

    Posted 04 Mar 2011 Link to this post

    thank you shinu...
  7. Suresh
    Suresh avatar
    2 posts
    Member since:
    Mar 2008

    Posted 16 Jul 2012 Link to this post

    How could this be done application wide?

    Thanks,

    Suresh.C
  8. Martin
    Martin avatar
    3 posts
    Member since:
    Sep 2011

    Posted 20 Aug 2012 Link to this post

    This is great and honestly super simple.

    Thank you.
  9. Amol
    Amol avatar
    2 posts
    Member since:
    Sep 2012

    Posted 17 Sep 2012 Link to this post

    Hi there,

    you can use following code...

     .Pageable(paging => paging.PageSize(5, new[] { 5, 10, 25, 50, 100, 200 }).Style(GridPagerStyles.NextPreviousAndNumeric | GridPagerStyles.PageSizeDropDown).Position(GridPagerPosition.Bottom))

    you just need to add  "new[] { 15,50,150,250 }" line to pageSize method

    thank you,
    Amol
  10. Tassilo
    Tassilo avatar
    3 posts
    Member since:
    Nov 2014

    Posted 20 Jul 2017 in reply to Joshua Link to this post

     <PagerStyle PageSizes="500,1000,5000,10000" />
Back to Top