Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Grid / Custom Paging

Custom paging, grouping and filtering on 100000 items using NeedDataSource
Drag a column header and drop it here to group by that column
IDNameUnit PriceDateDiscontinued
Page size:
select
 100000 items in 10000 pages
0Gula Malacca$3.00Monday, May 12, 2008
1Côte de Blaye$23.25Monday, May 12, 2008
2Spegesild$3.00Thursday, May 10, 2007
3Gula Malacca$9.00Tuesday, August 26, 2008
4Zaanse koeken$14.00Monday, May 12, 2008
5Côte de Blaye$19.00Thursday, July 31, 2008
6Côte de Blaye$23.25Friday, February 22, 2008
7Côte de Blaye$45.60Monday, May 12, 2008
8Spegesild$3.00Friday, February 22, 2008
9Singaporean Hokkien Fried Mee$3.00Friday, April 13, 2007


Custom paging, grouping and filtering on 100000 items using ObjectDataSource
Drag a column header and drop it here to group by that column
IDNameUnit PriceDateDiscontinued
Page size:
select
 100000 items in 10000 pages
0Zaanse koeken$263.50Saturday, January 19, 2008
1Singaporean Hokkien Fried Mee$23.25Saturday, January 19, 2008
2Spegesild$18.40Tuesday, August 26, 2008
3Gula Malacca$14.00Thursday, May 10, 2007
4Gula Malacca$32.00Thursday, May 10, 2007
5Boston Crab Meat$14.00Monday, May 12, 2008
6Spegesild$32.00Thursday, May 10, 2007
7Gula Malacca$9.00Friday, April 13, 2007
8Côte de Blaye$32.00Tuesday, August 26, 2008
9Rogede sild$18.40Friday, February 22, 2008

  • There are cases in which you may want to fetch only a fixed number of records and perform operations over this specified set of data. Telerik RadGrid allows such data manipulation through the custom paging mechanism integrated in the control. The main steps you need to undertake are:
    • Set AllowPaging = true and AllowCustomPaging = true for your grid instance
    • Implement code logic which to extract merely a fixed number of records from the grid source and present them in the grid structure
    • The total number of records in the grid source should be defined through the VirtualItemCount property of the MasterTableView/GridTableView instance. Thus the grid "understands" that the data source contains the specified number of records and it should fetch merely part of them at a time to execute requested operation.
    This example demonstrates the approach for custom paging depicted above. The simulated "DataLayer" wraps the logic for extracting records only for the specified page (along with deleting records option). Telerik RadGrid maintains the pager buttons, changing of pager and other presentation specific features.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="c#" Inherits="Telerik.GridExamplesCSharp.Programming.CustomPaging.DefaultCS"
        CodeFile="DefaultCS.aspx.cs" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="telerik" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <telerik:HeadTag runat="server" ID="Headtag2"></telerik:HeadTag>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
            <telerik:Header runat="server" ID="Header1" NavigationLanguage="CS"></telerik:Header>
       <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
            <!-- content start -->
            <telerik:RadAjaxManager ID="RadAjaxManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel1"
                runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="RadGrid2">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
            </telerik:RadAjaxLoadingPanel>
            <b>Custom paging, grouping and filtering</b> on <b>100000</b> items using <b>NeedDataSource</b>
            <telerik:RadGrid ID="RadGrid1" ShowGroupPanel="true" AllowFilteringByColumn="true"
                Width="95%" ShowStatusBar="true" runat="server" AllowPaging="True" AllowSorting="true"
                AllowCustomPaging="True" VirtualItemCount="100000" OnNeedDataSource="RadGrid1_NeedDataSource"
                OnGroupsChanging="RadGrid1_GroupsChanging" OnColumnCreated="RadGrid1_ColumnCreated">
                <ClientSettings AllowDragToGroup="true" />
                <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
            </telerik:RadGrid>
            <br />
            <br />
            <b>Custom paging, grouping and filtering</b> on <b>100000</b> items using <b>ObjectDataSource</b>
            <telerik:RadGrid ID="RadGrid2" AllowSorting="true" DataSourceID="ObjectDataSource1"
                ShowGroupPanel="true" AllowFilteringByColumn="true" Width="95%" ShowStatusBar="true"
                runat="server" AllowPaging="True" OnColumnCreated="RadGrid2_ColumnCreated">
                <ClientSettings AllowDragToGroup="true" />
                <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
                <MasterTableView OverrideDataSourceControlSorting="true" />
            </telerik:RadGrid>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" EnablePaging="true" SelectCountMethod="SelectCount"
    SelectMethod="Select" TypeName="Telerik.Web.Examples.Grid.MyBusinessObjectCollection">

            </asp:ObjectDataSource>
            <!-- content end -->
            <telerik:Footer runat="server" ID="Footer1"></telerik:Footer>
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451