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

RadGrid with "ALL" option in the page size combo box

36 Answers 928 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Asok
Top achievements
Rank 1
Asok asked on 26 Feb 2011, 09:35 PM
Hello,

I want to add "ALL" option to my RadGrid Page Size combo. I want the options 50,100,150,ALL. I know we can customize the page size option. However when I am adding the "ALL" option, it is returning an error "Input string was not in correct format". The requirement is when selecting the "ALL" option I want to show all the records in the Grid.

Please advise!

Thank you,
Asok

36 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Feb 2011, 11:01 AM
Hello Asok,

I have tried the same scenario and that worked fine at my end. Here I am pasting my code please make a double check with your code.
C#:
protected void rad_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.
0
levs
Top achievements
Rank 1
answered on 20 Jul 2011, 09:55 AM
Hi Shinu,

For your sample, the PageSizeComboBox_SelectedIndexChanged is not getting fired.
Any suggestion?

Thanks,

-levs
0
Shinu
Top achievements
Rank 2
answered on 20 Jul 2011, 11:14 AM
Hello Levs,

I tried to recreate the issue but no aval. I hope the following approach helps you to solve the issue.
How to Add "Show All" option in RadGrid Paging.

Thanks,
Shinu.
0
Stan
Top achievements
Rank 1
answered on 17 Aug 2011, 02:41 PM
Shinu:

Your solution
protected void LineItems_ItemEvent(object sender, GridItemEventArgs e)
        {
            if (e.EventInfo is GridInitializePagerItem)
            {
                TotalItemCount = (e.EventInfo as GridInitializePagerItem).PagingManager.DataSourceCount;
            }
        }
  
protected void LineItems_ItemCreated(object sender, GridItemEventArgs e)
       {
                if (e.Item is GridPagerItem)
                {
                    GridPagerItem pagerItem = (GridPagerItem)e.Item;
                    RadComboBox pageSizeComboBox = (RadComboBox)pagerItem.FindControl("PageSizeComboBox");
                    RadComboBoxItem allItem = new RadComboBoxItem();
                    allItem = new RadComboBoxItem("All", TotalItemCount.ToString());
                    allItem.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
                    pageSizeComboBox.Items.Add(allItem);
                }
      }
works, but there is one problem with it. When page size is changed to "All" the grid displays all the items, but the pager combox box value is 10 and not "All". Available page sizes in the combo box are 10, 20, 30, 50 and All. Changing page size to any item except All retains the value, but All does not.

Can you tell how to fix it?

Thanks,
-Stan
0
Maria Ilieva
Telerik team
answered on 22 Aug 2011, 03:49 PM
Hello Stan,

 Please try to set the current pagesize as the selected value like this:
pageSizeComboBox .Items.FindItemByValue(grid.PageSize.ToString()).Selected = true;



All the best,
Maria Ilieva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
B
Top achievements
Rank 1
answered on 07 Oct 2011, 03:04 PM
I have the same problem, implemented the solution as posted and have one usability issue:
--> On page load, the pager combo box shows '10, 20, 50, All'. Great!
--> On selection of 'All' the pager adds an additional item and selects it.. '10, 20, 50, 68, All'
--> On my Grid, there is a RadComboBox Filter that I use to filter the results by state. So, after a user 'views all' for say, 'AK', the pager box says '68' instead of 'All', which means when I select another state (i.e. 'AL') I see the first 68 results, instead of seeing 'All'.

To make this make more sense, let me put it this way:

Using the provided code, when I select the 'All' option, an additional list item is added to the RadComboBox 'PageSizeComboBox', with a value of the # of records for the current data source. So instead of the 'All' option being selected, a new list item is automatically added. This is not the behavior we want, or expect.

What I want, is simply, an 'All' option, that when selected, persists as the selected option, and continues to return all results, even after the filter has been changed.

Code I'm using is:
private int TotalItemCount;
protected void rgRecords_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridPagerItem)
    {
        GridPagerItem pagerItem = (GridPagerItem)e.Item;
        RadComboBox PageSizeCombo = (RadComboBox)pagerItem.FindControl("PageSizeComboBox");
        RadComboBoxItem item1 = new RadComboBoxItem();
        item1 = new RadComboBoxItem("All", TotalItemCount.ToString());
        item1.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
        PageSizeCombo.Items.Add(item1);
        PageSizeCombo.Items.FindItemByValue(rgRecords.PageSize.ToString()).Selected = true;
    }
}
 
protected void rgRecords_ItemEvent(object sender, GridItemEventArgs e)
{
    if (e.EventInfo is GridInitializePagerItem)
    {
        TotalItemCount = (e.EventInfo as GridInitializePagerItem).PagingManager.DataSourceCount;
    }
}
0
Maria Ilieva
Telerik team
answered on 12 Oct 2011, 09:38 AM
Hello,

Try to set the pagesize for "All" to int.MaxValue as described in the forum thread below and verify of this helps:
http://www.telerik.com/community/forums/aspnet-ajax/grid/show-all-option-on-the-pager.aspx

Greetings,
Maria Ilieva
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
B
Top achievements
Rank 1
answered on 12 Oct 2011, 02:03 PM
Hi Maria,

Great. Now the only problem left is that, after selecting the 'All' option, the combo box adds a new list item, with the value '2147483647'. Is there not a way for an user to select 'All' and for that option to stay persisted through page use? I do not understand why the option 'All' when selected, always adds a new list item to the drop down, instead of staying selected.

Thanks, -B
0
B
Top achievements
Rank 1
answered on 12 Oct 2011, 02:24 PM
Does Telerik even have a solution? Why are we paying the subscription price, when we can't even 'show all records' is a major concern and question for me. The question is, if I have to write my own pager for something as simple as 'Show All Records' why am I even using a Telerik product to begin with? Why does Telerik have a GRID control with no method or otherwise answer on how to 'Show All Records'?

If anybody does have an answer, or anyone representing Telerik that'd like to keep a current and paid subscriber, sure I'm all ears. However, I only ask that you only reply with a SOLUTION to this problem since I don't have time to keep trying things that don't work.

Again, my problem is:

I have a select box with 10, 20, 50 and [All]. I am adding the all option by using this code:
protected void rgRecords_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridPagerItem)
            {
                RadComboBox combo = (e.Item as GridPagerItem).FindControl("PageSizeComboBox") as RadComboBox;
                RadComboBoxItem item = new RadComboBoxItem("All", int.MaxValue.ToString());
                item.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
                combo.Items.Add(item);
                combo.Items.FindItemByValue(rgRecords.PageSize.ToString()).Selected = true;
            }
        }

  In any web browser (FireFox, Opera, IE, Chrome), when the user selects the 'All' option, a 5th option is added to the drop down list with a value of '2147483647' (int.MaxValue). Not what we want. We want the user to select 'All' and all records to show, and that the drop down list remains unmodified... So when the user selects 'All', the drop down list should contain '10, 20, 50, All' and 'All' should stay selected. Please, no more examples that create page artifacts.

Thanks! -B
0
B
Top achievements
Rank 1
answered on 12 Oct 2011, 02:28 PM
Maybe, someone at Telerik could create a new, sample / test solution, with Visual Studio 2010, using the latest stable release of the Telerik RadGrid, and SHOW us that an 'All' option can be created and used without creating page artifacts!

Please, begging for a sample project with a RadGrid, that has an 'All' option, that when selected stays selected.
0
Maria Ilieva
Telerik team
answered on 17 Oct 2011, 08:32 AM
Hi,

Find attached a sample runnable application which works correctly in all browsers wilt the latest official Q2 2011 SP1 release. Test it on your side and let me know if it works for you.

Best wishes,
Maria Ilieva
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
B
Top achievements
Rank 1
answered on 21 Oct 2011, 04:58 PM
This is the code that works (does not leave a page artifact).

if (e.Item is GridPagerItem)
            {
                RadComboBox combo = (e.Item as GridPagerItem).FindControl("PageSizeComboBox") as RadComboBox;
                RadComboBoxItem item = new RadComboBoxItem("All", int.MaxValue.ToString());
                item.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
                combo.Items.Add(item);
                if (rgRecords.PageSize == int.MaxValue)
                {
                    combo.Items.FindItemByText("All").Selected = true;
                }
                else
                {
                    combo.Items.FindItemByValue(rgRecords.PageSize.ToString()).Selected = true;
                }
                RadComboBoxItem extraItem = combo.Items.FindItemByText(int.MaxValue.ToString());
                if (extraItem != null)
                {
                    combo.Items.Remove(extraItem);
                }
            }
0
christian
Top achievements
Rank 1
answered on 21 Nov 2011, 01:29 PM
works great indeed!

the only thing I added was setting the pager style of the MasterTableView to "allways visible", otherwise the pager disappears as soon as you select "all".
0
Pramit Agrawal
Top achievements
Rank 1
answered on 02 Jul 2012, 11:49 AM
Hi,

When I select option All, pager control display "8 items in 0 pages". Pager control should display "8 items in 1 pages".
0
Jayesh Goyani
Top achievements
Rank 2
answered on 02 Jul 2012, 01:35 PM
0
kahuna
Top achievements
Rank 1
answered on 02 Jul 2012, 02:26 PM

Hi Pramit... 

I.E. 1 Pages is not proper English, it should be 1 Page. To fix your issue, use Page_PreRender (if you only have a BOTTOM pager, you do not have to do this in the Page_PreRender event. However, if you have both a TOP and BOTTOM pager, then this code must be here, since when the TOP pager is created in the RadGrid_ItemCreated event, it does not know how many items there are in the grid. So you MUST do this after the grid has been created.)

protected void Page_PreRender(object sender, EventArgs e)
        {
            //Fix page count in pager
            if (rgRecords.MasterTableView.Items.Count == 0)
            {
                rgRecords.MasterTableView.PagerStyle.PagerTextFormat = "{4}<strong>0</strong> items in <strong>0</strong> pages";
            }
            else if (rgRecords.MasterTableView.Items.Count == 1)
            {
                rgRecords.MasterTableView.PagerStyle.PagerTextFormat = "{4}<strong>{5}</strong> item in <strong>1</strong> page";
            }
            else if (rgRecords.PageSize == int.MaxValue || rgRecords.PageCount <= 1)
            {
                rgRecords.MasterTableView.PagerStyle.PagerTextFormat = "{4}<strong>{5}</strong> items in <strong>1</strong> page";
            }
            else
            {
                rgRecords.MasterTableView.PagerStyle.PagerTextFormat = "{4}<strong>{5}</strong> items in <strong>{1}</strong> pages";
            }
            rgRecords.Rebind(); //Must rebind for changes to take effect.
        }
0
Pramit Agrawal
Top achievements
Rank 1
answered on 03 Jul 2012, 06:32 AM
HI Kahuna,

Thanks for your reply.

I have only Bottom pager. Where I should right code to show correct english in pager.

Thanks
Pramit
0
Pramit Agrawal
Top achievements
Rank 1
answered on 03 Jul 2012, 06:43 AM
Hi Jayesh,

After adding the item into combobox it should be selected. You have one line missing in your code.

pageSizeCombo.FindItemByValue(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;

 

Initially I have the same code then I change my code to use int.MaxValue for "All" option. Problem in this code is, When "All" option is selected in pager and user Add/Delete any record in grid. It will give to runtime error. e.Item.OwnerTableView.PageSize is not increase/decrease and above line thru runtime error.

I solve this issue by adding if statement

if (rgRecords.PageSize == int.MaxValue)

{
pageSizeCombo.Items.FindItemByText("All").Selected = true;
}
else
{
pageSizeCombo.Items.FindItemByValue(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;
}


But Now problem is, When I add any item in grid, It Add item in next page, despite "All" option is selected in PagerComboBox.

Thanks
Pramit

0
kahuna
Top achievements
Rank 1
answered on 03 Jul 2012, 12:58 PM

Hi Pramit,

Unless you are opposed to using Page_PreRender, I would still use that same method. Full code listing to add the All option, and to have the pager display the correct tense for # of items and # of pages:

ASPX:

<telerik:RadGrid ID="rgRecords" runat="server" AllowSorting="true" AllowPaging="true" AutoGenerateColumns="false" Width="100%" PageSize="20" Skin="WebBlue" OnNeedDataSource="rgRecords_NeedDataSource" OnItemCreated="rgRecords_ItemCreated">
            <MasterTableView CommandItemDisplay="None">
                <NoRecordsTemplate>
  
                </NoRecordsTemplate>
                <Columns>
  
                </Columns>
                <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" Position="TopAndBottom" />
            </MasterTableView>
        </telerik:RadGrid>

C#:

protected void Page_Load(object sender, EventArgs e)
        {
            Page.PreRender += new EventHandler(Page_PreRender);
        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            //Fix page count in pager
            if (rgRecords.MasterTableView.Items.Count == 0)
            {
                rgRecords.MasterTableView.PagerStyle.PagerTextFormat = "{4}<strong>0</strong> items in <strong>0</strong> pages";
            }
            else if (rgRecords.MasterTableView.Items.Count == 1)
            {
                rgRecords.MasterTableView.PagerStyle.PagerTextFormat = "{4}<strong>{5}</strong> item in <strong>1</strong> page";
            }
            else if (rgRecords.PageSize == int.MaxValue || rgRecords.PageCount <= 1)
            {
                rgRecords.MasterTableView.PagerStyle.PagerTextFormat = "{4}<strong>{5}</strong> items in <strong>1</strong> page";
            }
            else
            {
                rgRecords.MasterTableView.PagerStyle.PagerTextFormat = "{4}<strong>{5}</strong> items in <strong>{1}</strong> pages";
            }
            rgRecords.Rebind(); //Must rebind for changes to take effect.
        }
        protected void rgRecords_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridPagerItem)
            {
                GridPagerItem gpi = e.Item as GridPagerItem;
  
                //Give pager drop down an 'All' option.
                RadComboBox combo = gpi.FindControl("PageSizeComboBox") as RadComboBox;
                if (combo != null)
                {
                    RadComboBoxItem item = new RadComboBoxItem("All", int.MaxValue.ToString());
                    item.Attributes.Add("ownerTableViewId", gpi.OwnerTableView.ClientID);
                    combo.Items.Add(item);
                    if (rgRecords.PageSize == int.MaxValue) { combo.Items.FindItemByText("All").Selected = true; }
                    else { combo.Items.FindItemByValue(rgRecords.PageSize.ToString()).Selected = true; }
                    if (combo.Items.FindItemByText(int.MaxValue.ToString()) != null) { combo.Items.Remove(combo.Items.FindItemByText(int.MaxValue.ToString())); }
                }
            }
        }
        protected void rgRecords_NeedDataSource(object sender, EventArgs e)
        {
//Set your data source here.
        }



0
Strang
Top achievements
Rank 1
answered on 12 Jul 2012, 09:53 PM
Hi Pramit,

There is pretty simple solution to have always "1 pages of 1" for "All" option: use (int.MaxValue-1) instead of (int.MaxValue).
It works at least in Telerik RadControls ASP.NET AJAX 2010Q3.
RadComboBoxItem item = new RadComboBoxItem("All", (int.MaxValue-1).ToString());

WBR,
Sergey Arkhipov.
0
Kevin
Top achievements
Rank 1
answered on 24 Aug 2012, 09:47 PM
I've been using the solution that was supplied in the zip file attached by Maria Ilieva in the thread.  It has worked pretty well for me but there's a bug with it that I've been unable to work through.  Take Maria's solution exactly as is but add CommandItemDisplay="Bottom" to the MasterTableView and then add a CommandItemTemplate for insert like this 
<CommandItemTemplate>
   <div>
      <asp:Button CommandName="InitInsert" CssClass="rgAdd" RunAt="Server"/>
      <asp:LinkButton CommandName="InitInsert" RunAt="Server">New User</asp:LinkButton>
   </div>
</CommandItemTemplate>

Load the page, select "All" for the PageSize, then click the insert button.  I get an error "Specified argument was out of the range of valid values." in the call stack at GridTableView::set_CurrentPageIndex(), GridTableView::InsertItem().

Is there a solution for this?

Thanks,
Kevin
0
Maria Ilieva
Telerik team
answered on 29 Aug 2012, 12:01 PM
Hi Kevin,

Find attached the modified version of the application which works correctly for the insert item scenario you are implementing. Test it on your end and let me know if it covers your requirements.

Greetings,
Maria Ilieva
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
Rohan
Top achievements
Rank 1
answered on 11 Oct 2012, 02:02 PM
Hi Maria llieva,
i have same requirement for rad grid and i am referencing  your code ="AllPaging-modified.zip" to add "All" option to page size drop down.
i am able to do this but when i am clicking to Add new record button it gives me exception
exception was-
Specified argument was out of the range of valid values. Parameter name: value
and source of exception
Telerik.Web.UI.GridTableView.set_CurrentPageIndex
0
Maria Ilieva
Telerik team
answered on 16 Oct 2012, 08:39 AM
Hello Rohan,

I tested again the previously provided application and was not bale to replicate the error you are facing. See the movie below which shows my local tests and let me know if I'm missing something:
http://screencast.com/t/7bWDYiyQWL

Please do let me know if you have applied any modification on the application so that the issue starts to appear.

Regards,
Maria Ilieva
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
Rohan
Top achievements
Rank 1
answered on 16 Oct 2012, 03:33 PM
Hi Maria llieva,

Thanks for replay ...

I solve issues with page size "all" option by setting GridInsertItemPageIndexAction.ShowItemOnFirstPage.
0
Rohan
Top achievements
Rank 1
answered on 20 Oct 2012, 09:28 AM
Hi Maria llieva,
Thanks for replay ,
now i am facing the new issues with delete - when i am fire delete command of radgrid it gives same exception

exception was-
Specified argument was out of the range of valid values. Parameter name: value
and source of exception
Telerik.Web.UI.GridTableView.set_CurrentPageIndex
0
Maria Ilieva
Telerik team
answered on 25 Oct 2012, 08:36 AM
Hi Rohan,

I further tested the previously provided project but I'm not able to replicate the mentioned errors on my end. Could I kindly ask you to open  regular support ticket and send us your version of the application so we could test is locally and advise you on the problem?

Greetings,
Maria Ilieva
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
Rohan
Top achievements
Rank 1
answered on 01 Nov 2012, 11:53 AM

 Hi Maria,

Thanks for replay ,,

sorry i am not getting appropriate forum link to post this problem....
 
I want to create Rad Grid as user control , so I can easy update my lots of grid's on  my application . I have create one user control for rad grid as per my business functionality and various properties ….

Now I stuck on one point how can I pass the different  columns to my user control grid. I have tried creating GridColumnCollection as one type of property but it not working … how can I pass my column list to user control, to generate rad grid according column and columns type.

Thank you
0
Maria Ilieva
Telerik team
answered on 06 Nov 2012, 10:32 AM
Hi Rohan,

It will be best to open a new forum thread or a support ticket and post your requirements there. Thus we will be able to easily track the different case you have and provide the most appropriate solution for each specific case.

Greetings,
Maria Ilieva
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
Yetrus
Top achievements
Rank 1
answered on 26 Dec 2012, 02:14 PM

hi friends

I got a problem with this, I need to set a pager Dropdownlist with 20,30,40 
It's working, the rows are displayed, but the selection in the dropdownlist is back to the first item (20)
any idea ??
greeting !!

if (e.Item is GridPagerItem)
   {
      // ---------------------------------------------------------
      // This is how to add items to the RadGrid Pager ComboBox
      // and to adjust the width of the RadGrid Pager dropdown.
      // ---------------------------------------------------------
      GridPagerItem oGridPagerItem = (GridPagerItem)e.Item;
      RadComboBox oRadComboBox = (RadComboBox)oGridPagerItem.FindControl("PageSizeComboBox");
      oRadComboBox.Width = Unit.Pixel(50);
      oRadComboBox.Items.Clear();
      RadComboBoxItem oItem = new RadComboBoxItem("20", "20");
      oItem.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
      oRadComboBox.Items.Add(oItem);
 
      oItem = new RadComboBoxItem("30", "30");
      oItem.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
      oRadComboBox.Items.Add(oItem);
 
      oItem = new RadComboBoxItem("40", "40");
      oItem.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
      oRadComboBox.Items.Add(oItem);
 
   }

0
Jayesh Goyani
Top achievements
Rank 2
answered on 27 Dec 2012, 04:14 AM
Hello,

Please check commented code / notes in below link.

http://jayeshgoyani.blogspot.in/2012/06/customizing-items-of-radgrid-page-size.html

Thanks,
Jayesh Goyani
0
Yetrus
Top achievements
Rank 1
answered on 27 Dec 2012, 12:49 PM

it works with this!!
thanks !!
greeting !!

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridPagerItem)
    {
 
       // ---------------------------------------------------------
       // This is how to add items to the RadGrid Pager ComboBox
       // and to adjust the width of the RadGrid Pager dropdown.
       // ---------------------------------------------------------
       GridPagerItem oGridPagerItem = (GridPagerItem)e.Item;
       RadComboBox oRadComboBox = (RadComboBox)oGridPagerItem.FindControl("PageSizeComboBox");
       oRadComboBox.Width = Unit.Pixel(50);
       oRadComboBox.Items.Clear();
       RadComboBoxItem oItem = new RadComboBoxItem("20", "20");
       oItem.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
       oRadComboBox.Items.Add(oItem);
 
       oItem = new RadComboBoxItem("30", "30");
       oItem.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
       oRadComboBox.Items.Add(oItem);
 
       oItem = new RadComboBoxItem("40", "40");
       oItem.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
       oRadComboBox.Items.Add(oItem);
       if (Session["PageSize"] != null)
       {
          oRadComboBox.SelectedIndex = Convert.ToInt32(Session["PageSize"].ToString());
       }
    }
 }
  
    protected void RadGrid1_PageSizeChanged(object sender, GridPageSizeChangedEventArgs e)
 {
    //RadComboBox ddl = (RadComboBox)sender;
 
    switch (((RadGrid)sender).PageSize)
    {
       case 20:
          Session["PageSize"] = 1;
          break;
       case 30:
          Session["PageSize"] = 2;
          break;
       case 40:
          Session["PageSize"] = 3;
 
          break;
    }
    //     Session["PageSize"] = ((RadGrid)sender).PageSize;
 }
0
Robert
Top achievements
Rank 1
answered on 07 Mar 2013, 09:17 PM
This code attached in AllPaging.zip has a bug. After you select "All" from the page size list, if you click on either the next page or last page button navigation button, the website throws an ArgumentOutOfRangeException. This is happening on my website as well where I copied to code to add the "All" option. Is there a way to fix this?
0
Maria Ilieva
Telerik team
answered on 12 Mar 2013, 03:20 PM
Hi Robert,

I tested the application on my end again and was not bale to replicate the error you mentioned. I would suggest you to open a separate support ticket and report the issue there so that we could further investigate the problem and track the issue in a timely matter.

Greetings,
Maria Ilieva
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
Shawn
Top achievements
Rank 1
answered on 28 Jul 2014, 04:11 PM
I found an easy way to add an 'All' option. Just add a page size of max int size and then change the combo box text to 'All' for that option.
HTML:
<PagerStyle Mode="NextPrevAndNumeric" PageSizeLabelText="Page Size: " PageSizes="50,100,200,2147483647" Position="TopAndBottom" AlwaysVisible="true" />

CodeBehind:
protected void RadGrid1_OnItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridPagerItem) 
        { 
// Change the text of the int.max value to 'All'
            RadComboBox combo = (e.Item as GridPagerItem).FindControl("PageSizeComboBox") as RadComboBox; 
combo.Items[3].Text = "All";
         } 
0
Daniel
Top achievements
Rank 1
answered on 30 Jan 2017, 09:08 PM
Protected Sub rgAudit_ItemCreated(sender As Object, e As GridItemEventArgs)      
 
        If (TypeOf (e.Item) Is GridPagerItem) Then           
            Dim pager As GridPagerItem = e.Item
            Dim pageSizeCombobox As RadComboBox = pager.FindControl("PageSizeComboBox")
            Dim comboItem As RadComboBoxItem = New RadComboBoxItem("All", integer.MaxValue)
            comboItem.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID)
            pageSizeCombobox.Items.Add(comboItem)
 
            If pageSizeCombobox.SelectedValue = Integer.MaxValue Then
                pageSizeCombobox.Items.FindItemByText("All").Selected = true
                rgAudit.PageSize = pageSizeCombobox.SelectedValue           
            End If
 
            Dim extraItem As RadComboBoxItem = pageSizeCombobox.Items.FindItemByText(integer.MaxValue.ToString())
 
            If Not extraItem Is Nothing Then
                pageSizeCombobox.Items.Remove(extraItem)
            End If
             
        End If
    End Sub

 

Here is how I got it to work, this fixes setting the dropdown to all, adding all, and adjusting the list.

Tags
Grid
Asked by
Asok
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
levs
Top achievements
Rank 1
Stan
Top achievements
Rank 1
Maria Ilieva
Telerik team
B
Top achievements
Rank 1
christian
Top achievements
Rank 1
Pramit Agrawal
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
kahuna
Top achievements
Rank 1
Strang
Top achievements
Rank 1
Kevin
Top achievements
Rank 1
Rohan
Top achievements
Rank 1
Yetrus
Top achievements
Rank 1
Robert
Top achievements
Rank 1
Shawn
Top achievements
Rank 1
Daniel
Top achievements
Rank 1
Share this question
or