Add controls to pager

2 posts, 0 answers
  1. George Handlin
    George Handlin avatar
    5 posts
    Member since:
    Mar 2006

    Posted 30 Jan 2015 Link to this post

    I'm trying to add a label and checkbox after the Page Size drop down in the standard pager. However, when I do this:

    protected void AssetGrid_OnItemEvent(object sender, GridItemEventArgs e)
    {
        if (e.EventInfo is GridInitializePagerItem)
        {
            var showAllLabel = new Label {Text = "Show All"};
            var showAllCheckBox = new CheckBox();
     
            (e.Item as GridPagerItem).PagerContentCell.Controls.Add(showAllLabel);
            (e.Item as GridPagerItem).PagerContentCell.Controls.Add(showAllCheckBox);
        }
    }

    The result is the controls above the whole pager. 
  2. Eyup
    Admin
    Eyup avatar
    3013 posts

    Posted 04 Feb 2015 Link to this post

    Hello George,

    You can use the following approach to achieve the requested functionality:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridPagerItem)
        {
            GridPagerItem pager = e.Item as GridPagerItem;
            RadComboBox combo = pager.FindControl("PageSizeComboBox") as RadComboBox;
            Panel cell = combo.Parent as Panel;
     
            Label showAllLabel = new Label { Text = "Show All" };
            CheckBox showAllCheckBox = new CheckBox();
     
            cell.Controls.Add(showAllLabel);
            cell.Controls.Add(showAllCheckBox);
        }
    }

    Hope this helps. Please give it a try and let me know if it works for you.

    Regards,
    Eyup
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top