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

[Solved] RadGrid Groupin Pagesize change Restriction

3 Answers 151 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manishkumar
Top achievements
Rank 1
Manishkumar asked on 12 Nov 2009, 05:15 AM
Hi,

I am using RadGrid with Grouping feature. Also, at the bottom i have Pagesize Change option with textbox.

Now, Is it possible for me to have combo box in place of pagesie change text box ?

I would like to restrict user to certain pagesizes only like 5,10,15,20 and no other cusotm text. Or is there any way by which i can restrict user to enter less than some numer for pagesize lets say 20?

Request you to please suggest.

Thanks and regards,
Manish Patel


3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 12 Nov 2009, 06:34 AM
Hi Manish Patel,

Set the PagerStyle-Mode to "NextPrevAndNumeric" in order to get the dropdown for changing the pagesize.

      <MasterTableView PageSize="20" DataSourceID="SqlDataSource1">
       <PagerStyle Mode="NextPrevAndNumeric" />

You can customize the dropdown options by using following code snippet in ItemDataBound event of RadGrid.
CS:
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridPagerItem) 
        { 
            RadComboBox PageSizeCombo = (RadComboBox)e.Item.FindControl("PageSizeComboBox"); 
 
            PageSizeCombo.Items.Clear(); 
            PageSizeCombo.Items.Add(new RadComboBoxItem("5")); 
            PageSizeCombo.FindItemByText("5").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID); 
            PageSizeCombo.Items.Add(new RadComboBoxItem("10")); 
            PageSizeCombo.FindItemByText("10").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID); 
            PageSizeCombo.Items.Add(new RadComboBoxItem("15")); 
            PageSizeCombo.FindItemByText("15").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID); 
            PageSizeCombo.Items.Add(new RadComboBoxItem("20")); 
            PageSizeCombo.FindItemByText("20").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID); 
 
            PageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true
        }  
    } 

Regards,
Shinu.
0
Manishkumar
Top achievements
Rank 1
answered on 12 Nov 2009, 06:51 AM
Thanks for Reply..it solves the issue..!

I also want to display footer text "Page 1 of 2, items 1 to 5 of 10"  always but not the pagination buttons.

AlwaysVisible = true display Prev Next buttons as well all the times. I would liek to hide them when i am on the last page and display page size combo and text to the right.

Please sugegst.

Thanks!

Manish

0
Sebastian
Telerik team
answered on 17 Nov 2009, 10:04 AM
Hello Manishkumar,

The built-in page modes supported by RadGrid for ASP.NET AJAX are presented in this page from the online documentation. In case you would like to make your pager more flexible and customizable (in par with your preferences), consider using pager template and control its fields and their visibility in conjunction with your conventions.

Kind regards,
Sebastian
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.
Tags
Grid
Asked by
Manishkumar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Manishkumar
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or