I am trying to get a RadGrid to support both Virtualization and Custom Paging. I can get either to work fine, but not both together. This is my code for NeedDataSource below. It seems that CurrentPageIndex is always set to 0. I would expect that to increment with the virtual scrolling.
protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
int startRowIndex = RadGrid1.CurrentPageIndex * RadGrid1.PageSize;
int maxRows = RadGrid1.PageSize;
var reportDetails = DataAccess.GetReportDetails(Convert.ToInt32(reportSummary["ReportSummaryId"]), startRowIndex, maxRows);
RadGrid1.DataSource = reportDetails;
}
protected void RadAjaxPanel_Init(object sender, EventArgs e)
{
//SET THE TOTAL # OF ROWS IN THE OVERALL REPORT
string userKey = Common.GetUserKeyFromCookie(Request);
DataTable reportSummaryTable = DataAccess.GetReportSummary(userKey, "SelectFollows");
reportSummary = reportSummaryTable.Rows[0];
int recordCount = Convert.ToInt32(reportSummary["RecordCount"]);
RadGrid1.MasterTableView.VirtualItemCount = recordCount;
RadGrid1.VirtualItemCount = recordCount;
}
The code from my ASPX is:
<telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel" OnInit="RadAjaxPanel_Init" LoadingPanelID="RadAjaxLoadingPanel1">
<telerik:RadGrid AutoGenerateColumns="False" ID="RadGrid1" PageSize="100" OnNeedDataSource="RadGrid1_NeedDataSource" runat="server">
<PagerStyle Mode="NextPrevAndNumeric" />
<GroupingSettings CaseSensitive="false" />
<MasterTableView AllowCustomPaging="true" AllowPaging="true" TableLayout="Fixed">
<Columns>
<telerik:GridBoundColumn UniqueName="ScreenName" HeaderText="ScreenName" HeaderStyle-Width="250px" DataField="ScreenName"></telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="ProfileImage" HeaderText="Photo" HeaderStyle-Width="250px" DataField="ProfileImage"></telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings ReorderColumnsOnClient="true" AllowColumnsReorder="true" ColumnsReorderMethod="Reorder">
<Virtualization EnableVirtualization="true" InitiallyCachedItemsCount="100"
LoadingPanelID="RadAjaxLoadingPanel1" ItemsPerView="100" />
<Scrolling AllowScroll="true" EnableVirtualScrollPaging="true" UseStaticHeaders="true" ScrollHeight="500px" />
<Resizing AllowColumnResize="true" />
</ClientSettings>
<PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
</telerik:RadGrid>
</telerik:RadAjaxPanel>
protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
int startRowIndex = RadGrid1.CurrentPageIndex * RadGrid1.PageSize;
int maxRows = RadGrid1.PageSize;
var reportDetails = DataAccess.GetReportDetails(Convert.ToInt32(reportSummary["ReportSummaryId"]), startRowIndex, maxRows);
RadGrid1.DataSource = reportDetails;
}
protected void RadAjaxPanel_Init(object sender, EventArgs e)
{
//SET THE TOTAL # OF ROWS IN THE OVERALL REPORT
string userKey = Common.GetUserKeyFromCookie(Request);
DataTable reportSummaryTable = DataAccess.GetReportSummary(userKey, "SelectFollows");
reportSummary = reportSummaryTable.Rows[0];
int recordCount = Convert.ToInt32(reportSummary["RecordCount"]);
RadGrid1.MasterTableView.VirtualItemCount = recordCount;
RadGrid1.VirtualItemCount = recordCount;
}
The code from my ASPX is:
<telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel" OnInit="RadAjaxPanel_Init" LoadingPanelID="RadAjaxLoadingPanel1">
<telerik:RadGrid AutoGenerateColumns="False" ID="RadGrid1" PageSize="100" OnNeedDataSource="RadGrid1_NeedDataSource" runat="server">
<PagerStyle Mode="NextPrevAndNumeric" />
<GroupingSettings CaseSensitive="false" />
<MasterTableView AllowCustomPaging="true" AllowPaging="true" TableLayout="Fixed">
<Columns>
<telerik:GridBoundColumn UniqueName="ScreenName" HeaderText="ScreenName" HeaderStyle-Width="250px" DataField="ScreenName"></telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="ProfileImage" HeaderText="Photo" HeaderStyle-Width="250px" DataField="ProfileImage"></telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings ReorderColumnsOnClient="true" AllowColumnsReorder="true" ColumnsReorderMethod="Reorder">
<Virtualization EnableVirtualization="true" InitiallyCachedItemsCount="100"
LoadingPanelID="RadAjaxLoadingPanel1" ItemsPerView="100" />
<Scrolling AllowScroll="true" EnableVirtualScrollPaging="true" UseStaticHeaders="true" ScrollHeight="500px" />
<Resizing AllowColumnResize="true" />
</ClientSettings>
<PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
</telerik:RadGrid>
</telerik:RadAjaxPanel>