Customized Page size

18 posts, 0 answers
  1. Appu
    Appu avatar
    61 posts
    Member since:
    Jun 2009

    Posted 01 Jul 2009 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Jul 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 01 Jul 2009 Link to this post

    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.
  5. Appu
    Appu avatar
    61 posts
    Member since:
    Jun 2009

    Posted 01 Jul 2009 Link to this post

    Hi Shinu..
        as per the method ur given it is working fine, i could addcustomized paging to my Pager combo

    Thanx
    Appu
  6. Boone
    Boone avatar
    47 posts
    Member since:
    May 2008

    Posted 28 Oct 2009 Link to this post

    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 
            } 


  7. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 28 Oct 2009 Link to this post

    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

  8. Boone
    Boone avatar
    47 posts
    Member since:
    May 2008

    Posted 28 Oct 2009 Link to this post

    GridSearchResults_PageChanged never gets called. That's my issue.
  9. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 29 Oct 2009 Link to this post

    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> 
  10. Andrew
    Andrew avatar
    14 posts
    Member since:
    Apr 2009

    Posted 12 Jan 2010 Link to this post

    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
  11. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 12 Jan 2010 Link to this post

    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.
  12. Andrew
    Andrew avatar
    14 posts
    Member since:
    Apr 2009

    Posted 12 Jan 2010 Link to this post

    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
  13. Ajith Nair
    Ajith Nair avatar
    11 posts
    Member since:
    Oct 2012

    Posted 29 Jun 2010 Link to this post

    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 .
  14. Matt
    Matt avatar
    58 posts
    Member since:
    Jun 2009

    Posted 05 Jul 2010 Link to this post

    FYI: Pavlinas method worked fine out the box :)
  15. nanthakumar thangavel
    nanthakumar thangavel avatar
    27 posts
    Member since:
    Nov 2009

    Posted 23 Jul 2010 Link to this post

    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

  16. Fit2Page
    Fit2Page avatar
    345 posts
    Member since:
    Feb 2007

    Posted 20 Aug 2010 Link to this post

    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
  17. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 24 Aug 2010 Link to this post

    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
  18. Eon
    Eon avatar
    15 posts
    Member since:
    Apr 2015

    Posted 05 Jan in reply to Shinu Link to this post

    Thanks Shinu's

     

    Your answer help me.

  19. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 07 Jan Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017