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

Customized Page size

17 Answers 1258 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Appu
Top achievements
Rank 1
Appu asked on 01 Jul 2009, 11:27 AM
Hi

        Is there any psossiblity to customize page size which is displaying pager status bar.
By default when i set the Page Size to 50 it automaticaaly creates dropdown for 10,20,50 like.

But my intention is i need to cutomize the default flow filling into Page size drop down to 100,150,300,500,1000 like.

Hope u could understand what i meant, plz help me..

Regards,
SA

17 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Jul 2009, 01:01 PM
Hi Appu,

Try out the following approach in order to show customized options for radgrid PageSize dropdown.

ASPX:
 
<telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowSelection="true" AllowPaging="True" DataSourceID="SqlDataSource1"
    <MasterTableView AutoGenerateColumns="False" PageSize="100" DataSourceID="SqlDataSource1"
        <PagerStyle Mode="NextPrevAndNumeric" /> 
        <Columns> 
         
        </Columns> 
    </MasterTableView> 
</telerik:RadGrid> 

C#:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if (e.Item is GridPagerItem) 
    { 
        RadComboBox PageSizeCombo = (RadComboBox)e.Item.FindControl("PageSizeComboBox"); 
        PageSizeCombo.Items[0].Text = "100"
        PageSizeCombo.Items[1].Text = "150"
        PageSizeCombo.Items[2].Text = "300"
        PageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;  
    } 

Thanks,
Shinu.
0
Pavlina
Telerik team
answered on 01 Jul 2009, 01:31 PM
Hello Appu,

I am sending you a simple runnable application that demonstrates the needed approach. Please give it a try and let me know if you have other questions or problems.
 
Kind regards,
Pavlina
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
Appu
Top achievements
Rank 1
answered on 01 Jul 2009, 04:45 PM
Hi Shinu..
    as per the method ur given it is working fine, i could addcustomized paging to my Pager combo

Thanx
Appu
0
Boone
Top achievements
Rank 2
answered on 28 Oct 2009, 06:31 PM
How would I track which page size they clicked?  This (OnPageSizeChanged="GridSearchResults_PageChanged") does not work for me. The records I was to track is in my <DetailTables><telerik:GridTableView section if that helps at all..

I was able to set the page size increments like above but would like to track what they click on in a cookie so that I can load the page size when they revisit the site.

protected void GridSearchResults_PageChanged(object source, GridPageSizeChangedEventArgs e) 
        { 
            //Set cookie here 
            //cookieName = gridName 
            //cookeiValue = pageSize they selected 
        } 


0
Casey
Top achievements
Rank 1
answered on 28 Oct 2009, 07:59 PM
Hi Boone,

To get the size they selected I believe you could use the "e.NewPageSize" attribute of the onpagesizechanged event of your RadGrid.

Hope this helps,
Casey

0
Boone
Top achievements
Rank 2
answered on 28 Oct 2009, 09:01 PM
GridSearchResults_PageChanged never gets called. That's my issue.
0
Casey
Top achievements
Rank 1
answered on 29 Oct 2009, 12:20 PM

Is that method attached to the OnPageSizeChanged event of your RadGrid? That is the only reason I can think of for the method not being hit.

<telerik:RadGrid ID="RadGrid1" runat="server" onpagesizechanged="RadGrid1_PageSizeChanged" > 
</telerik:RadGrid> 
0
Andrew
Top achievements
Rank 1
answered on 12 Jan 2010, 06:58 AM
I think I'm having a similar issue as mentioned above where now that I've customized my Paging Combo Box choices, when I select a value from that combo box nothing happens...it is like an event is no longer getting fired.  This grid worked just fine before customizing this code.  The code I added to customize the choices in my paging combo box is as follows:

    Protected Sub gridAudit_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles gridAudit.ItemDataBound  
        If TypeOf (e.Item) Is GridCommandItem Then 'hide add new item button  
            Dim addButton As Button = e.Item.FindControl("AddNewRecordButton")  
            addButton.Visible = False 
        End If 
        If TypeOf (e.Item) Is GridPagerItem Then 'customize grid paging options  
            Dim myPageSizeCombo As RadComboBox = e.Item.FindControl("PageSizeComboBox")  
            myPageSizeCombo.Items.Clear()  
            Dim arrPageSizes() As String = {"10""20""50""100""250""500"}  
            For x As Integer = 0 To UBound(arrPageSizes)  
                Dim myRadComboBoxItem As New RadComboBoxItem(arrPageSizes(x))  
                myPageSizeCombo.Items.Add(myRadComboBoxItem)  
            Next 
            myPageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = True 
        End If 
    End Sub 

Any ideas?  Thanks in advance...

Andrew
0
Princy
Top achievements
Rank 2
answered on 12 Jan 2010, 08:26 AM
Hello Andrew,

Try out a slight modification to your code (as shown below) and see if it helps..
vb:
Protected Sub gridAudit_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles gridAudit.ItemDataBound   
          'hide add new item button...
 
        If TypeOf (e.Item) Is GridPagerItem Then  
            Dim myPageSizeCombo As RadComboBox = e.Item.FindControl("PageSizeComboBox")   
            myPageSizeCombo.Items.Clear()   
            Dim arrPageSizes() As String = {"10""20""50""100""250""500"}   
            For x As Integer = 0 To UBound(arrPageSizes)   
                Dim myRadComboBoxItem As New RadComboBoxItem(arrPageSizes(x))   
                myPageSizeCombo.Items.Add(myRadComboBoxItem)   
                'add the following line
                myRadComboBoxItem.Attributes.Add("ownerTableViewId", gridAudit.MasterTableView.ClientID) 
            Next  
            myPageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = True  
        End If  
 End Sub  

-Princy.
0
Andrew
Top achievements
Rank 1
answered on 12 Jan 2010, 03:47 PM
Thanks so much, this resolved it.  Sounds like I needed to give each item in the combo box the ID of the grid on which to fire an event...thanks again!

Andrew
0
Ajith Nair
Top achievements
Rank 1
answered on 29 Jun 2010, 02:33 PM
Hi,
I have implemented your code and successfully customized the pager style.
here is my code
RadComboBoxItem item = new RadComboBoxItem("All", intTotalCount);
 item.Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);

This works fine. But the problem is after selecting the 'All' , the pager disappears. I tried the Alwaysvisible in the pagerstyle. but failed again.
Is there any way to keep the Pager visible after viewing all the data in the grid.

Thanks .
0
Matt
Top achievements
Rank 1
answered on 05 Jul 2010, 05:35 PM
FYI: Pavlinas method worked fine out the box :)
0
nanthakumar thangavel
Top achievements
Rank 1
answered on 23 Jul 2010, 11:06 AM
Hi

Try out  my code  (as shown below) and Custom PageSize with Clientside binding (when Clientside binding with service the  PageSize is  Double Time added Like 10,20,50,100,100,200  )  problem rectified

Private Sub SHRadGridNew_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles Me.ItemCreated
        Try
            If TypeOf (e.Item) Is GridPagerItem Then
                Dim myPageSizeLabel As Label = e.Item.FindControl("ChangePageSizeLabel")
                myPageSizeLabel.Text = "Records Per Page :"
 
                Dim myPageSizeCombo As RadComboBox = e.Item.FindControl("PageSizeComboBox")
                Dim arrPageSizes() As String = {"100", "200"}
                For x As Integer = 0 To UBound(arrPageSizes)
                    Dim myRadComboBoxItem As New RadComboBoxItem(arrPageSizes(x), arrPageSizes(x))
                    myRadComboBoxItem.Attributes.Add("ownerTableViewId", Me.MasterTableView.ClientID)
                    If myPageSizeCombo.Items.FindItemByValue(arrPageSizes(x)) Is Nothing Then
                        myPageSizeCombo.Items.Add(myRadComboBoxItem)
                    End If
                Next
                myPageSizeCombo.Items.Sort(New PagerRadComboBoxItemComparer())
                myPageSizeCombo.Items.FindItemByValue(Me.PageSize.ToString()).Selected = True
            End If
             
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

0
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
answered on 20 Aug 2010, 03:25 PM
Hi,

Why is it not possible to find the paging combobox and do

PageSizeCombo.Skin = "Default"
PageSizeCombo.EnableEmbeddedSkins = True

I want to use custom skin for grid but standard skin for the paging combo.
I get:

Telerik.Web.UI.RadComboBox with ID='PageSizeComboBox' was unable to find embedded skin with name 'Zuivelhoeve'. Please, make sure that you spelled the skin name correctly, or if you want to use a custom skin, set EnableEmbeddedSkins=false.


BR
0
Pavlina
Telerik team
answered on 24 Aug 2010, 03:26 PM
Hello,

The skin name of the pager combobox always matches the skin name of the RadGrid control. So if you are using a custom skin for RadGrid, you should use one for the RadComboBox as well.

However, to achieve your goal the custom skin name should matches with the embedded skin name(Default in your case). Then you can set EnableEmbeddedSkins="true" for the pager combobox in RadGrid.ItemCreated and the control will use its embedded skin.

Give this suggestion a try and let me know how it goes.

All the best,
Pavlina
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
Eon
Top achievements
Rank 1
answered on 05 Jan 2016, 02:25 PM

Thanks Shinu's

 

Your answer help me.

0
Pavlina
Telerik team
answered on 07 Jan 2016, 04:25 PM
Hello,

If you want to customize the grid pagesize instead of using this custom approach you can try with the build-in PageSizes property of the grid introduced since Q2 2012. PageSizes property determines the values that will be displayed in the PageSize combo box in the RadGrid pager item. 

Give this suggestion a try and let us know if the same issue with Client-side binding still persists.

Regards,
Pavlina
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Appu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Pavlina
Telerik team
Appu
Top achievements
Rank 1
Boone
Top achievements
Rank 2
Casey
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Ajith Nair
Top achievements
Rank 1
Matt
Top achievements
Rank 1
nanthakumar thangavel
Top achievements
Rank 1
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Eon
Top achievements
Rank 1
Share this question
or