This is a migrated thread and some comments may be shown as answers.

Page Size selection when PagerStyle Mode=Slider

9 Answers 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Martillo
Top achievements
Rank 2
Martillo asked on 10 May 2010, 03:27 AM
When the PagerStyle is set to "Slider", is there any way to offer the user a Page Size selection dropdown(similar to the one you get when the PagerStyle Mode is "NexPrevAndNumeric"?

Thanks.

9 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 May 2010, 07:54 AM
Hi Martillo,

Try the following code to add page size selection control to the pager item when the PagerStyle-Mode is "Slider".

   
    protected
 void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridPagerItem)  
        {  
            GridPagerItem pagerItem = (GridPagerItem)e.Item;  
  
            Label lblPager = new Label();  
            lblPager.ID = "PageSizeLabel";  
            lblPager.Text = "|  PageSize: ";  
  
            RadComboBox combo = new RadComboBox();  
            combo.ID = "PageSizeComboBox";  
            combo.AutoPostBack = true;             
            combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged);  
  
            // Adding items to combobox  
            combo.Items.Add(new RadComboBoxItem("10"));  
            combo.FindItemByText("10").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);  
            combo.Items.Add(new RadComboBoxItem("20"));  
            combo.FindItemByText("20").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);  
            combo.Items.Add(new RadComboBoxItem("50"));  
            combo.FindItemByText("50").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);  
  
            // Adding pagesize controls to slider's container  
            ((Panel)(pagerItem.FindControl("RadGrid1_SliderPagerLabel"))).Controls.Add(lblPager);  
            ((Panel)(pagerItem.FindControl("RadGrid1_SliderPagerLabel"))).Controls.Add(combo);  
  
            // Setting combobox text  
            combo.FindItemByText(RadGrid1.PageSize.ToString()).Selected = true;  
        }  
    }  
  
    void combo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)  
    {  
        RadGrid1.PageSize = Convert.ToInt32(((RadComboBox)o).SelectedItem.Text);  
        RadGrid1.Rebind();  
    }  

Regards,
Princy.
0
Martillo
Top achievements
Rank 2
answered on 10 May 2010, 03:26 PM
Hello Princy,

Thank you for the code. It looks good, however I'm getting a null reference error on the following line:

 ((Panel)(pagerItem.FindControl("RadGrid1_SliderPagerLabel"))).Controls.Add(lblPager);   

When I search the HTML source, I can find the ID:

div id="ctl00_ContentPlaceHolder_RadGrid1_ctl00_ctl02_ctl00_ctl00_ContentPlaceHolder_RadGrid1_SliderPagerLabel" class="rgSliderLabel"

I will work on debugging this later...

Thanks again,

Martillo


0
Ram
Top achievements
Rank 1
answered on 23 Aug 2011, 12:41 PM
Hi
I'm using radgrid in my application.
I have palced the radgrid inside asp:udatepanel.
When I load page first time the slider of radggrid not proper in appearence.in "Firefox"
Its like in attached file.
Its happen only first time. If do paging then its ok, but when I first generate the report its happeings.
please help me
0
Princy
Top achievements
Rank 2
answered on 23 Aug 2011, 01:03 PM
Hello Ram,

I cannot reproduce the issue at my end. 2011, 1, 315, 35 is the version in which I tested and it worked as expected.

Thanks,
Princy.
0
Ram
Top achievements
Rank 1
answered on 23 Aug 2011, 02:05 PM
My version is 2011.1.519.40
How cloud I solve this problem.
I have placed the grid in side asp:updatepanel for updating conditionally on button click event.
0
Welch
Top achievements
Rank 1
answered on 09 Jul 2013, 08:21 PM
Martillo,

What did you do to resolve the null reference error?
0
Eyup
Telerik team
answered on 15 Jul 2013, 08:41 AM
Hi Welch,

I am attaching a sample RadGrid web site to demonstrate how you can add new controls to the slider pager item. Please run the attached application and let me know if it helps you.

Regards,
Eyup
Telerik
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 the blog feed now.
0
rd
Top achievements
Rank 1
answered on 09 Apr 2014, 03:19 PM
Hello.

For me the code works great but only inside a Page, I'm trying to use it in a UserControl but without success.
Everytime I run, ((Panel)(pagerItem.FindControl("RadGrid1_SliderPagerLabel"))) is always null.

I'm loading the UserControl to a Placeholder inside my default page.
My Telerik.Web.UI version is 2013.3.1114.40.
0
Eyup
Telerik team
answered on 14 Apr 2014, 12:59 PM
Hello,

Can you please check the approach demonstrated in the RadGridPagerTemplateSlider.zip and let me know about the result?

Looking forward to hearing from 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.

 
Tags
Grid
Asked by
Martillo
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Martillo
Top achievements
Rank 2
Ram
Top achievements
Rank 1
Welch
Top achievements
Rank 1
Eyup
Telerik team
rd
Top achievements
Rank 1
Share this question
or