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

CurrentPageIndex not updating right away

1 Answer 201 Views
This is a migrated thread and some comments may be shown as answers.
Beth M
Top achievements
Rank 1
Beth M asked on 21 Jun 2010, 07:46 PM
I'm trying to implement virtual scrolling, and it's working great, except that the currentpageindex doesn't update immediately..  I open the page, and it loads page 0.  Then I scroll down, the loading symbol shows, it displays data - same data as page 0.  If I hit 'refresh', it then loads the correct data.  Or, if I scroll down another page (so now the pager says I'm on page 2) it updates and shows me the page 1 data - it's one page behind.  Did I miss a rebind call?  I'm using NeedDataSource, though, and so I don't need to put that in there, right?

Here's my radgrid tag:

    <PagerStyle Mode="NumericPages" /> 
        <CommandItemSettings ShowAddNewRecordButton="False"></CommandItemSettings> 
            <telerik:GridBoundColumn Visible="False" DataField="name" HeaderText="Name" UniqueName="name"></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn Visible="False" DataField="classname" HeaderText="Class Name" UniqueName="classname"></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn Visible="False" DataField="identifier" HeaderText="Identifier" UniqueName="identifier"></telerik:GridBoundColumn> 
    <GroupingSettings ShowUnGroupButton="True"></GroupingSettings> 
    <SortingSettings SortToolTip="name" /> 
    <ClientSettings AllowDragToGroup="true"
                SaveScrollPosition="True" /> 

And my vb NeedDataSource function:
Protected Sub RadGrid1_NeedDataSource(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource 
    Dim sql As String 
    Dim cmd As OracleCommand 
    Dim row_count As Integer = 1 
    ' Open connection 
    ' Set up sql command 
    sql = "db_search" 
    cmd = New OracleCommand(sql, conn) 
    cmd.CommandType = CommandType.StoredProcedure 
    ' Add parameters 
    cmd.Parameters.Add("row_start", OracleDbType.Decimal, RadGrid1.CurrentPageIndex * RadGrid1.PageSize, ParameterDirection.Input) 
    cmd.Parameters.Add("row_end", OracleDbType.Decimal, (RadGrid1.CurrentPageIndex + 1) * RadGrid1.PageSize, ParameterDirection.Input) 
    cmd.Parameters.Add("db_cur", OracleDbType.RefCursor, ParameterDirection.Output) 
    ' Get row count (cut out this part for brevity, it does update it though) 
    Me.RadGrid1.VirtualItemCount = row_count 
    ' Set as the datasource 
    Dim da As New OracleDataAdapter(cmd) 
    Dim ds As New DataSet() 
    Me.RadGrid1.DataSource = ds 
    ' Cleanup 
End Sub 

I looked at this thread but it did not fix my issue, as well as various documentation for paging and virtual scrolling, and haven't found a solution yet.  Thanks in advance for any advice!

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 24 Jun 2010, 08:50 AM
Hello Beth M,

I have tried the code bellow and it works as expected on my side. My suggestion is to open a formal support ticket and send us a runnable sample that demonstrates your scenario. This way we would be able to track the cause of the issue and provide you with more to-the-point resolution.


<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Vista" />
<telerik:RadGrid ID="RadGrid1" Skin="Vista" runat="server" PageSize="15" AllowPaging="True"
    AllowCustomPaging="True" AllowSorting="True" OnNeedDataSource="RadGrid1_NeedDataSource">
    <PagerStyle Mode="NumericPages" />
    <MasterTableView AutoGenerateColumns="False">
            <telerik:GridBoundColumn DataField="Col1" HeaderText="Col1" UniqueName="Col1">
            <telerik:GridBoundColumn DataField="Col2" HeaderText="Col2" UniqueName="Col2">
            <telerik:GridBoundColumn DataField="Col3" HeaderText="Col3" UniqueName="Col3">
        <Scrolling AllowScroll="True" EnableVirtualScrollPaging="True" UseStaticHeaders="True"
            SaveScrollPosition="True" />

Code behind:

private DataTable GetDataTable()
    DataTable table;
    if (ViewState["Table"] == null)
        table = new DataTable();
        table.Columns.Add("Col1", typeof(int));
        for (int i = 0; i < 1000; i++)
            table.Rows.Add(i, "Col2", "Col3" + i);
        ViewState["Table"] = table;
        table = ViewState["Table"] as DataTable;
    return table;
protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    RadGrid1.VirtualItemCount = 1000;
    DataSet dataSet = new DataSet();
    RadGrid1.DataSource = GetDataTable().Select("Col1 >= " + ((RadGrid1.CurrentPageIndex * RadGrid1.PageSize)) + " AND Col1 <" + ((RadGrid1.CurrentPageIndex + 1) * RadGrid1.PageSize));

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
Asked by
Beth M
Top achievements
Rank 1
Answers by
Telerik team
Share this question