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

Adding additional paging size limits

4 Answers 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Samir Vaidya
Top achievements
Rank 1
Samir Vaidya asked on 16 Jun 2011, 08:23 PM
I have turned on paging in my RadGrid control and the default limits for number of items per page are 10, 25 and 50.  However, I would also like to add additional limits for items per page for 75 and 100 in the dropdown list.

Is there a way to accomplish this in the RadGrid control?  If so, what are the settings that I need to modify?

Thanks.

4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 17 Jun 2011, 09:38 AM
hi,

protected void rad_ItemCreated(object sender, GridItemEventArgs e)
    {
    if (e.Item is  GridPagerItem)
        {
            GridPagerItem pager = (GridPagerItem)e.Item;
            RadComboBox PageSizeComboBox = (RadComboBox)pager.FindControl("PageSizeComboBox");
// add item by this way.
//            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,
Jayesh Goyani
0
Princy
Top achievements
Rank 2
answered on 17 Jun 2011, 09:39 AM
Hello Samir,

Try the following code snippet in ItemCreated event to change the default limits for number of items in a page. Hope this helps.

C#:
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
       if (e.Item is GridPagerItem)           
        {
            GridPagerItem pagerItem = (GridPagerItem)e.Item;
            RadComboBox PageSizeCombo = (RadComboBox)pagerItem.FindControl("PageSizeComboBox");                 
            RadComboBoxItem item = new RadComboBoxItem();
            item = new RadComboBoxItem("75");
            item.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
            PageSizeCombo.Items.Add(item);
        }
}

Thanks,
Princy.
0
Samir Vaidya
Top achievements
Rank 1
answered on 23 Jun 2011, 01:40 AM
The code that Princy provided works, however, when I Page through the RadGrid, the selection in the ComboBox is not retained.  In addition, if I add 2 values to the Paging Combobox such as 75 and 100, I get a duplicate of the 75 value upon paging through the Grid as well.

Please advise.
0
Pavlina
Telerik team
answered on 23 Jun 2011, 09:47 AM
Hi Samir,

I followed your scenario and prepared a sample project which handles the desired functionality. You can find the example attached to this message. Please check it out and let me know if it works for you.

Greetings,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Samir Vaidya
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Samir Vaidya
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or