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

How to remove "Page Size" dropdown

44 Answers 1084 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ksuh
Top achievements
Rank 1
Veteran
ksuh asked on 15 Apr 2009, 10:23 PM
I do not want this combobox to appear.  How do I remove it?

44 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Apr 2009, 03:49 AM
Hi Ksuh,

Try the following code snippet to achieve the desired scenario.

CS:
 
 
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
      
        if (e.Item is GridPagerItem) 
        { 
            GridPagerItem pager = (GridPagerItem)e.Item; 
            RadComboBox PageSizeComboBox = (RadComboBox)pager.FindControl("PageSizeComboBox"); 
            PageSizeComboBox.Visible = false
        } 
    } 


Shinu
0
Daniel
Telerik team
answered on 16 Apr 2009, 08:26 AM
Hello Kwang,

You may easily remove it using CSS:
.rgAdvPart 
    displaynone

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ksuh
Top achievements
Rank 1
Veteran
answered on 17 Apr 2009, 03:54 PM
Fan-freaking-tastic.  Both solutions are total hacks.

I guess I'll have to wait another year for someone at Telerik to put in a "ShowPageSize" attribute.
0
Daniel
Telerik team
answered on 17 Apr 2009, 05:46 PM
Hello Kwang,

We appreciate your opinion. Our developers will consider your idea to expose a  property as you suggested.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ksuh
Top achievements
Rank 1
Veteran
answered on 29 May 2009, 05:08 PM
I see that this is still not done for the latest release.  Is there an ETA for this?
0
Dimo
Telerik team
answered on 02 Jun 2009, 08:24 AM
Hello Kwang,

The PagerStyle Modes, which are available out-of-the-box, offer predefined pager layout and content. We have evaluated your request, but I am afraid we do not intend to introduce properties to further customize these predefined pager modes. In order to hide the combobox, please use the one of the approaches provided above or customize the pager, according to the online examples and help articles:

Pager Template Demo
Pager Template Help Article

Programmatic Pager Customization Demo
Programmatic Pager Customization Help Article


Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Grendizer
Top achievements
Rank 1
answered on 09 Jun 2009, 09:25 AM
Hello Daniel,

It would have be nice to have each pager block of the Advanced Part to get identified by a specific className.

Sure by doing

.rgAdvPart { displaynone; } 

We would hide the Page Size drop down, but in NextPrevNumericAndAdvanced mode, the page navigator would also get hidden.

Now we can't simply hide the desired part because if you try to do
.rgPager .rgAdvPart .rgPagerLabel,  
.rgPager .rgAdvPart .rgPagerButton  
{  
    displaynone;  
both content would get hidden.

Ok I can still use a Pager Template but it would require to go through all my grids ...
and what I what is just o hide this page size stuff :-(

Any feedback on that would be appreciated.

Thanks.
0
Dimo
Telerik team
answered on 09 Jun 2009, 10:16 AM
Hi Grendizer,

Actually the RadGrid pager has a unique CSS class, which corresponds to the Pager Mode. So in order to hide the RadComboBox and its label only in the NextPrevAndNumeric pager mode, you can use:

.NextPrevAndNumeric  .rgAdvPart { display: none; }


Greetings,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Grendizer
Top achievements
Rank 1
answered on 09 Jun 2009, 12:42 PM
Hello Dimo,

Thanks for your quick update.

I'm sorry if I was not clear enough but my issue is not related to a specific mode ... in fact, my issue is more about dealing with content of this rgAdvPart element.

I would like to hide the Page Size block but to keep the Page Goto block, and by doing it with provided CSS  would hide everything.

Thanks.

Seb
0
Dimo
Telerik team
answered on 09 Jun 2009, 01:36 PM
Hello Grendizer,

Now I see. Well, in order to accomplish that, you must use a programmatic approach and set Visible="false" to the following controls:

ChangePageSizeLabel
ChangePageSizeTextBox
ChangePageSizeLinkButton

(these are the IDs which can be used by the FindControl method)


Sincerely yours,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Grendizer
Top achievements
Rank 1
answered on 09 Jun 2009, 01:51 PM
Thanks for your quick update.

Do you have any pattern to do this globally once for all grids or do I have to do it for every instance of the grid ?!

If I have to do it for every grids, is it much appropriate than doing a custom pager template based on existing one ?!

Regards.
0
Dimo
Telerik team
answered on 09 Jun 2009, 02:11 PM
Hi Grendizer,

Since the customization has to be carried out at runtime, naturally, it has to be implemented for every RadGrid control. In this case (re)using a pager template is better.

Best wishes,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Grendizer
Top achievements
Rank 1
answered on 09 Jun 2009, 02:45 PM
Dimo,

Thanks for your support, I'll try to handle it this way.

Regards.
0
Mink
Top achievements
Rank 1
answered on 17 Jul 2009, 12:49 PM
Hi Dimo,

I can understand your position on having a couple of predefined PagerStyle Modes on one hand and the possibility of defining your own pager template on the other. However, making a template that is for example exactly the same as NextPrevAndNumeric but only without the page size controls seems a bit to much work for such a simple wish.

Now if you'd want something done as simple as that you could of course use the css trick .rgAdvPart{ display:none;} as described by Daniel, but as other pointed out such a simple solution does not work for other slightly more complicated situations.
For me, I wouldn't expect NextPrevAndNumeric to contain something "advanced" such as the ability to choose the page size, since there is also the NextPrevNumericAndAdvanced mode. I would say that the difference between both is the advanced part and seeing as choosing the page size is advanced it should be part of the none-advanced NextPrevAndNumeric.

Maybe a good in between solution would be to offer a few more out-of-the-box PagerStyle Modes. For example one that's exactly like NextPrevAndNumeric but without the page size choosing bit.

Regards,

Mink
0
Dimo
Telerik team
answered on 17 Jul 2009, 12:57 PM
Hi Mink,

Thank you for sharing your opinion. We might consider adding more pager modes in the future.

Sincerely yours,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jeff Reinhardt
Top achievements
Rank 1
answered on 15 Oct 2009, 02:43 PM
In the ItemCreated this works to hide the Page Size Combo:

 


if

 

(e.Item is GridPagerItem)

 

{

 

GridPagerItem pagerItem = (GridPagerItem)e.Item;

 

 

RadComboBox PageSizeComboBox = (RadComboBox)pagerItem.FindControl("PageSizeComboBox");

 

PageSizeComboBox.Visible =

false;

 

}

but the LABEL is still there.     Page Size:     sitting there in the header and footer of the grid.

How can I remove it?

0
Princy
Top achievements
Rank 2
answered on 16 Oct 2009, 06:48 AM
Hello Jeff,

The PageSize label can be accessed by using its Control id, which is, ChangePageSizeLabel  and passing the id over in the FindControl method. take a look at the code below:
c#:
 protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if(e.Item is GridPagerItem) 
        { 
            GridPagerItem pagerItem = (GridPagerItem)e.Item; 
            RadComboBox PageSizeComboBox = (RadComboBox)pagerItem.FindControl("PageSizeComboBox"); 
            PageSizeComboBox.Visible = false
            Label changePageSizelbl = (Label)pagerItem.FindControl("ChangePageSizeLabel"); 
            changePageSizelbl.Visible = false
        } 
    } 

Thanks
Princy.
0
Waqas Akram
Top achievements
Rank 1
answered on 23 Oct 2009, 01:27 PM
That's cool... Works for us... Thanks for the post
0
skysailor
Top achievements
Rank 1
answered on 26 Oct 2009, 01:08 AM
Hi,
Supporting a fixed set of modes with layouts is fine. It would be nice to have more of these modes though. The thing that annoyed me is that between versions you added a new control to an existing layout. You should have create a new mode for the new controls (page size). This has made existing code not work as designed. You should avoid these breaking changes where possible.
Clayton
0
Rebecca Rasmussen
Top achievements
Rank 2
answered on 28 Dec 2009, 03:02 PM
"between versions you added a new control to an existing layout. ... [please also] create a new mode for the new controls (page size)

I second this concept. I recently upgraded to 2009 q3 from a 2008 version, and voila, now I'm having to go in a remove the new page control from the pager in all of my grids (because we have a single page-size control in our footer that affects all grids in our application as our users wanted to be able to set this once and be done).

Very painful!

It would be swell if when you add a new control to an existing item you also make it very easy to hide for those that are happy with the existing layout and do not want to utilize the new control. :)
0
Dimo
Telerik team
answered on 28 Dec 2009, 03:05 PM
Hello Rebecca,

The easiest way to remove the dropdown is with a CSS rule:

.NextPrevAndNumeric  .rgAdvPart { display: none; }

Sincerely yours,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
skysailor
Top achievements
Rank 1
answered on 28 Dec 2009, 10:04 PM
Hi,
The point here is not how to implement a work around. But that you should not make breaking changes when not absolutely necessary.
Clayton
0
Toby
Top achievements
Rank 1
answered on 17 Feb 2010, 10:20 AM
Just to say I completely agree with ksuh, there should just be a property whether to show the pagesize combo or not, which is how it is done on most of grid controls. Its not like its something that is going to be complicated to add for the developers either.

thanks
Toby
0
Neil
Top achievements
Rank 1
answered on 09 Apr 2010, 02:58 AM
This feature appeared out of nowhere, and is stuck (unless you hack it off).  Why is Telerik so against giving a more legit solution to not show the Change Page Size drop down?!!   It doesn't always work anyway. 

You've already told us there's a CSS and code-behind way to "remove" it.   So please stop repetitively posting it like it's what we've been asking for.
0
Dimo
Telerik team
answered on 09 Apr 2010, 08:40 AM
Hello Neil,

We understand that the predefined pager layouts may not suite all scenarios and developers, but our goal is to keep them as simple (in terms of configuration and implementation) as possible.

Greetings,
Dimo
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Manuel Romero
Top achievements
Rank 1
answered on 08 Sep 2011, 07:30 PM
Having controls cluttered with features that cannot easily be turned off with properties does not make them "simple". It makes them harder to work with.
0
Peter
Top achievements
Rank 1
answered on 02 May 2012, 02:57 AM
Is this fixed yet?

I should be be able to hide the Page Size combo box with either a PagerStyle or MasterTableView setting.
0
Richard
Top achievements
Rank 1
answered on 03 May 2012, 07:52 PM
Peter:

This was not a bug in RadGrid, so it did not require fixing.

Here's the method that can be used for hiding the PageSize combo box  and the associated label:

    protected void RadGrid1_ItemDataBound1(object sender, GridItemEventArgs e)
    {
 
        if (e.Item is GridPagerItem)
        {
            GridPagerItem pager = (GridPagerItem)e.Item;
            Label lbl = (Label)pager.FindControl("ChangePageSizeLabel");
            lbl.Visible = false;
             
            RadComboBox combo = (RadComboBox)pager.FindControl("PageSizeComboBox");
            combo.Visible = false;
        }
 
    }
 
}

More detail is available in this forum thread.

Hope this helps!
0
ksuh
Top achievements
Rank 1
Veteran
answered on 03 May 2012, 08:07 PM
Well I guess this "feature" is still bothering a lot of people.

It is not a bug.  However, it was an unexpected change in behaviour that some people, including myself, found no use for when the current previous implementation was the one that was wanted.

Your solution is a hack.  I have around 30 grids I have to apply this "fix" for.  It is a maintenance annoyance, not to mention that this needs to be done every new grid that gets created. 
0
Tsvetina
Telerik team
answered on 07 May 2012, 08:26 AM
Hi,

If you have a lot of grids and you want all of them to not display the dropdown, why not use the CSS rule suggested in one of the previous posts by Dimo:
.NextPrevAndNumeric  .rgAdvPart { display: none; }

You only add it once in your page's stylesheets and you do not need to do anything else to hide the page size combo in the numerous grids.

If needed, you could make the selector(s) even more specific, so that the rule does not hide other controls if you are allowing the user to switch modes.

Greetings,
Tsvetina
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.
0
ksuh
Top achievements
Rank 1
Veteran
answered on 07 May 2012, 05:31 PM
Because the combobox is still rendered, that's why!
0
Tsvetina
Telerik team
answered on 10 May 2012, 11:21 AM
Hello,

Other options are to declare a pager template as per your requirements and reuse it in the different grids, or if all your grids are identical, you can have a user control with the grid declaration and reuse it instead of adding the code-behind to hide the grid in each page.
Anyway, if you would like this, you can submit a Feature Request through the ticketing system and post your requirement to our developement team there, so that they can again consider it or add it to PITS for voting by the community.

Greetings,
Tsvetina
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.
0
Bill
Top achievements
Rank 1
answered on 16 Jan 2013, 09:36 PM
I see 2 solutions posted...one uses the ItemCreated method and one uses the ItemDataBound method.
Do both work or is one the correct one to use?

I also want to support some of the previous posts in that this type of simple behavior (to hide a Page Size dropdown) should be provided without the need to do coding using the controls names.  Will Telerik guarantee that these control names and property names will NEVER change????

And if this Page Size was added to an existing pager-style, then I also have to agree with the previous posts that this is completely unacceptable side-affect behavior. 

Thank you
0
Shinu
Top achievements
Rank 2
answered on 17 Jan 2013, 06:10 AM
Hi,

You can access the pager controls in either ItemCreated or ItemDataBound event by using the ID's of the controls in the pager depending on each mode. Also check the following help documentation for more details.
Accessing the Elements of Advanced Type Pager

Thanks,
Shinu
0
Bill
Top achievements
Rank 1
answered on 17 Jan 2013, 06:40 PM
Thanks.
I have this asp defining the type of pager as PagerStyle Mode="NextPrevNumericAndAdvanced"
I have put this in the code behind

 

protected void gridAgreementList_ItemDataBound(object sender, GridItemEventArgs e)

 

{

 

if (e.Item is GridPagerItem)

 

{

 

GridPagerItem pager = (GridPagerItem)e.Item;

 

 

Label lbl = (Label)pager.FindControl("ChangePageSizeLabel");

 

lbl.Visible =

false;

 

 

RadComboBox combo = (RadComboBox)pager.FindControl("PageSizeComboBox");

 

combo.Visible =

false;

 

}

}



And while the lvl.visible seems to work fine, the combo.visible line of code throws an exception "Object reference not set to an instance of an object."

That seems to mean it was not finding the control.

Any ideas?
0
Bill
Top achievements
Rank 1
answered on 17 Jan 2013, 07:12 PM
Further info for my previous post

here is the version of radgrid

<%

@ Register Assembly="Telerik.Web.UI, Version=2011.1.413.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4"

 

 

Namespace="Telerik.Web.UI" TagPrefix="rad" %>

 



And I have confirmed that the statement

    RadComboBox

 

combo = (RadComboBox)pager.FindControl("PageSizeComboBox");
is indeed returning null.  So there is no control with the name PageSizeComboBox.

0
Shinu
Top achievements
Rank 2
answered on 18 Jan 2013, 04:42 AM
Hi,

The PageSizeComboBox will be rendered only when the mode is NextPrevAndNumeric. Since the control is not rendered in NextPrevNumericAndAdvanced mode, the combobox will be null. Hope this helps.

Thanks,
Shinu
0
Bill
Top achievements
Rank 1
answered on 18 Jan 2013, 01:54 PM
Why are you saying my mode is not set right when I said in my post specifically:
    "I have this asp defining the type of pager as PagerStyle Mode="NextPrevNumericAndAdvanced""

Am I misreading something or are you?

Boy this process of 1 answer per day is frustrating especially when I post all the info I think you need and get an answer that doesn't take into account the info i provided. Sorry for sounding miffed but I am.  I don't mind if folks get things wrong (obviously I am doing something wrong myself) when we are chatting, but when turnaround time with this process is 1 day, you have to be careful to take the time to read all the post and understand it.

Is there a way to get faster (immediate) help as a licensed user of the product?

If it helps, here is the asp code:

<

 

rad:RadGrid ID="gridAgreementList" runat="server" Width="99%"

 

 

AutoGenerateColumns="False" EnableLinqExpressions="false"

 

 

Skin="Windows7" PageSize="10" AllowSorting="True" GridLines="Horizontal" CellPadding="0"

 

 

SortingSettings-EnableSkinSortStyles="false"

 

 

SortingSettings-SortedAscToolTip="<%$ Resources:UIText, SortedAscToolTip %>"

 

 

SortingSettings-SortedDescToolTip="<%$ Resources:UIText, SortedDescToolTip %>"

 

 

SortingSettings-SortToolTip="<%$ Resources:UIText, SortToolTip %>"

 

 

OnPageIndexChanged="gridAgreementList_PageIndexChanged" OnPageSizeChanged="gridAgreementList_PageSizeChanged"

 

 

OnSortCommand="gridAgreementList_SortCommand"

 

 

onitemdatabound="gridAgreementList_ItemDataBound">

 

 

<PagerStyle Mode="NextPrevNumericAndAdvanced" CssClass="quotePager" Position="TopAndBottom" HorizontalAlign="Center" />

 

0
Pavlina
Telerik team
answered on 23 Jan 2013, 03:10 PM
Hello,

As Shinu said PageSizeComboBox will be rendered only when the mode is NextPrevAndNumeric. Note that when PagerStyle.Mode is NextPrevNumericAndAdvanced as it is in your case in the grid pager there is no ComboBox control. Therefore when you try to find it you receive - Object reference not set to an instance of an object error.

Greetings,
Pavlina
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.
0
Bill
Top achievements
Rank 1
answered on 23 Jan 2013, 05:00 PM
According to http://www.telerik.com/help/aspnet-ajax/grid-pageritem.html, when the mode is NextPrevNumericAndAdvanced, there is a Page Size box.  I want to hide that control and its label. How can I do that?
0
Bill
Top achievements
Rank 1
answered on 23 Jan 2013, 09:45 PM
I have solved this.  Feel free to let me know if there is something not done properly.

 protected void gridAgreementList_ItemCreated(object sender, GridItemEventArgs e)
   {
      if (e.Item is GridPagerItem)
 
         // Hide controls related to the page size of the grid (i.e. # of rows to display)
         {
            Label changePageSizeLabel = (Label)e.Item.FindControl("ChangePageSizeLabel");
            changePageSizeLabel.Visible = false;

            Button changePageSizeLinkButton = (Button)e.Item.FindControl("ChangePageSizeLinkButton");
            changePageSizeLinkButton.Visible = false;

            RadNumericTextBox changePageSizeText = (RadNumericTextBox)e.Item.FindControl("ChangePageSizeTextBox");
            changePageSizeText.Visible = false;
         }
      }

0
he
Top achievements
Rank 1
answered on 05 Jul 2013, 03:07 AM
<PagerStyle ... PageSizeControlType="None"... />
0
FIT Bilgi islem Sistemleri Servis
Top achievements
Rank 1
answered on 07 Aug 2013, 07:10 AM
he, your solution

<PagerStyle PageSizeControlType="None" />

worked perfectly for me, thanks.
0
Anders
Top achievements
Rank 1
answered on 16 Aug 2017, 10:08 AM

If a solution of getting rid of the combobox is to hide it with css tricks (using css selectors that may change in the future) or remove it manually in code behinds (with a method that may not work in the future) instead of never have the combobox added to the element hierarchy in the first place the solution is a hack.

Cant we just agree about that?

Tags
Grid
Asked by
ksuh
Top achievements
Rank 1
Veteran
Answers by
Shinu
Top achievements
Rank 2
Daniel
Telerik team
ksuh
Top achievements
Rank 1
Veteran
Dimo
Telerik team
Grendizer
Top achievements
Rank 1
Mink
Top achievements
Rank 1
Jeff Reinhardt
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Waqas Akram
Top achievements
Rank 1
skysailor
Top achievements
Rank 1
Rebecca Rasmussen
Top achievements
Rank 2
Toby
Top achievements
Rank 1
Neil
Top achievements
Rank 1
Manuel Romero
Top achievements
Rank 1
Peter
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Tsvetina
Telerik team
Bill
Top achievements
Rank 1
Pavlina
Telerik team
he
Top achievements
Rank 1
FIT Bilgi islem Sistemleri Servis
Top achievements
Rank 1
Anders
Top achievements
Rank 1
Share this question
or