Customize Paging - Page Sizes

3 posts, 0 answers
  1. SHP
    SHP avatar
    8 posts
    Member since:
    Dec 2010

    Posted 02 Mar 2012 Link to this post

    I have seen solutions for this issue in the RadGrid forum but they don't work for TreeList.  Basically I want to replace the page size option with my own set, but when I do that using the following code it breaks paging (changing the page size basically does nothing).  Evidently there is some event-handling that needs to be hooked up.  How do I get this to work?? Thanks in advance!

     Dim ddPageSizes As Telerik.Web.UI.RadComboBox = CType(e.Item.FindControl("PageSizeComboBox"), Telerik.Web.UI.RadComboBox)

                        ddPageSizes.Items.Clear()

                        ddPageSizes.Items.Add(New Telerik.Web.UI.RadComboBoxItem("10"))
                        ddPageSizes.Items(0).Attributes.Add("ownerTableViewId", Me.EditResults.ClientID)
                        ddPageSizes.Items.Add(New Telerik.Web.UI.RadComboBoxItem("250"))
                        ddPageSizes.Items(1).Attributes.Add("ownerTableViewId", Me.EditResults.ClientID)
                        ddPageSizes.Items.Add(New Telerik.Web.UI.RadComboBoxItem("500"))
                        ddPageSizes.Items(2).Attributes.Add("ownerTableViewId", Me.EditResults.ClientID)

                        ddPageSizes.FindItemByText(Me.EditResults.PageSize.ToString()).Selected = True
  2. Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 07 Mar 2012 Link to this post

    Hello Sean,

    I have assembled a sample project demonstrating the desired functionality. The main steps for achieving your scenario are described below:
    • Subscribe to RadTreeList ItemCreated event
    • Find the pager RadComboBox and add all the items
    • Select the current PageSize in the combo
    protected void RadTreeList1_ItemCreated(object sender, Telerik.Web.UI.TreeListItemCreatedEventArgs e)
    {
        TreeListPagerItem pagerItem = e.Item as TreeListPagerItem;
     
        if (pagerItem != null)
        {
            RadComboBox combo = e.Item.FindControl("PageSizeComboBox") as RadComboBox;
            combo.Items.Clear();
            IList<int> defaultPageSizes = new List<int>();
            defaultPageSizes.Add(10);
            defaultPageSizes.Add(250);
            defaultPageSizes.Add(500);
            foreach (int size in defaultPageSizes)
            {
                RadComboBoxItem item = new RadComboBoxItem(size.ToString(), size.ToString());
                combo.Items.Add(item);
            }
            RadComboBoxItem comboBoxItem = combo.Items.FindItemByValue(pagerItem.OwnerTreeList.PageSize.ToString());
            if (comboBoxItem != null)
            {
                comboBoxItem.Selected = true;
            }
        }
    }

    Greetings,
    Antonio Stoilkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. SHP
    SHP avatar
    8 posts
    Member since:
    Dec 2010

    Posted 07 Mar 2012 Link to this post

    It works!  Thank you!!!!  I had actually tried that variation before but had mistakenly put the code into the ItemDataBound event handler instead of ItemCreated.  Thanks again!
Back to Top