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

RadGrid Pager Bug

3 Answers 35 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeanne
Top achievements
Rank 1
Jeanne asked on 01 Oct 2013, 06:49 PM
There is a bug in the RadGrid Pager when the page size is set to Integer.MaxValue (I added an "All" options to the page sizes). Instead of displaying "Page 1 of 1" it displays "Page 1 of 0". Some of the GridPagerItem.Paging values are also incorrect. Here is what they contain in the ItemCreated and ItemDataBound events:

Count = 21474483647
CurrentPageIndex = 0
DatasourceCount = 240
FirstIndexInPage = 0
IsFirstPage = True
IsLastPage = False
LastIndexInPage = 239
PageCount = 0
PageSize = 21474483647

This is the code I use to modify the page sizes dropdown list:
Public Sub SetPageSizes(oPagerItem As GridPagerItem, aSizes As String())
    Dim rcbPager As RadComboBox = DirectCast(oPagerItem.FindControl("PageSizeComboBox"), RadComboBox)
    Dim iTotalItems As Integer = oPagerItem.Paging.DataSourceCount
    rcbPager.Items.Clear()
    For Each sSize As String In aSizes
        Dim iSize As Integer = 0
        If sSize.ToUpper() = "ALL" Then
            iSize = Integer.MaxValue
        Else
            If Not Integer.TryParse(sSize, iSize) Then
                Continue For
            ElseIf iTotalItems < iSize Then
                Continue For
            End If
        End If
        Dim oNewItem As New RadComboBoxItem(sSize, iSize.ToString())
        oNewItem.Attributes.Add("ownerTableViewId", oPagerItem.OwnerTableView.ClientID)
        rcbPager.Items.Add(oNewItem)
    Next
    If iTotalItems > 0 Then
        Dim oItem As RadComboBoxItem = rcbPager.FindItemByValue(oPagerItem.OwnerTableView.PageSize.ToString())
        If oItem IsNot Nothing Then
            oItem.Selected = True
        End If
    End If
End Sub

There is another strange thing to in that, if I add the "All" item as the last item to the PageSizeComboBox as above, upon postback the .Text of the item is no longer "All", but the same as the .Value.

There's other strange behavior with the PageSizeComboBox items on postback as well. If I add an item to the end that contains a fairly small value, it gets sorted first instead of last, and the default items that I did not add back (like "20" and "50") still show up in the items list.

3 Answers, 1 is accepted

Sort by
0
Milena
Telerik team
answered on 04 Oct 2013, 11:39 AM
Hello,

There are some requirements when using custom paging mechanism of RadGrid. You can see them here. Could you please verify if your grid configuration meets these requirements?  Additionally, you can see in action the custom paging functionality in this online example.
Below is part of RadGrid`s code, we are using to get the page count of RadGrid:
public int PageCount
    {
                    get
                    {
                            if (! enumerable.SupportsPaging)
                            {
                                    return 1;
                            }
                            int count = this.DataSourceCount;
                            if (this.IsPagingEnabled && (count != 0))
                            {
                                    return (((count + this._pageSize) - 1) / this._pageSize);
                            }
                            return 1;
                    }
            }

In order int.MaxValue to not be overflowed, the biggest possible PageSize could be int.MaxValue - item count +1.


Regards,
Milena
Telerik
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 the blog feed now.
0
Jeanne
Top achievements
Rank 1
answered on 04 Oct 2013, 02:29 PM
I don't need to do custom paging, I just need an "All" option that works.

While know how you get the page count may be useful, Your reply does not address the fact that some of the GridPagerItem.Paging values are quite clearly incorrect.
0
Milena
Telerik team
answered on 09 Oct 2013, 08:51 AM
Hello,

Attached you can find a sample project, which demonstrates how the desired functionality can be achieved. Using this approach, all paging parameters are correct.

Regards,
Milena
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Jeanne
Top achievements
Rank 1
Answers by
Milena
Telerik team
Jeanne
Top achievements
Rank 1
Share this question
or