Custom Alpha Paging for RadGrid

Thread is closed for posting
3 posts, 0 answers
  1. 5EBF5A6A-BC81-4048-A21D-DEF5EAD982C6
    5EBF5A6A-BC81-4048-A21D-DEF5EAD982C6 avatar
    19 posts
    Member since:
    Jul 2005

    Posted 13 Sep 2006 Link to this post

    Requirements

    r.a.d.controls version

    Q2 2006

    .NET version

    .NET 1.1 or .NET 2.0

    Visual Studio version

    2005

    programming language

    C#

    browser support

    all browsers supported by r.a.d.controls


    Sample screenshot:

     

    PROJECT DESCRIPTION
    Enable custom alpha paging on the grid with multiple pages for single letter.
  2. F47B0E40-F952-4694-B1B3-6EF998FE1C12
    F47B0E40-F952-4694-B1B3-6EF998FE1C12 avatar
    48 posts
    Member since:
    Jul 2006

    Posted 14 Nov 2006 Link to this post

    Hi Vlad!!

    Thanx a lot.
    This example is too good. But I don't want paging in this way.
    I want normal and Alphabetic paging separately.

    Can I put alphabetic paging in Footer and the normal paging is in pager template? Plz. reply asap.
  3. C7498A83-7E2E-418C-8791-93EF573A7569
    C7498A83-7E2E-418C-8791-93EF573A7569 avatar
    9934 posts
    Member since:
    Nov 2016

    Posted 15 Nov 2006 Link to this post

    Hello Dhaval,

    Basically, there should be no difference where you position the link buttons in the grid (in the pager or footer) as long as you assign CommandName and CommandArgument for them. Thus the event bubbling mechanism of the grid should raise the ItemCommand event of the control on button click. Then you can intercept the command and filter the records in the grid in conjunction with the user's choice.

    Hence you may try hooking the ItemCreated event of the grid, check whether the item which is about to be created is footer item, create the link buttons for the alphabetic pager and add them in the footer. Below is some bare-bone logic:

    private void RadGrid1_ItemCreated(object sender, Telerik.WebControls.GridItemEventArgs e)  
    {  
     if (e.Item.ItemType == GridItemType.Footer)  
     {  
                GridFooterItem footerItem = (GridFooterItem)e.Item;  
                footerItem.Controls.Clear();  
                for (int i = 65; i <= 65 + 25; i++)  
                {  
                    int recordcount = DataSourceHelperCS.GetLetterCount(((char)i).ToString());  
                    int pagecount = (int)(recordcount / RadGrid1.PageSize);  
     
                    for (int j = 0; j <= pagecount; j++)  
                    {  
                        LinkButton linkButton1 = new LinkButton();  
                        LiteralControl lc = new LiteralControl();  
     
                        lc.Text = " ";  
                        linkButton1.Text = "" + (char)(i) + j.ToString();  
     
                        linkButton1.CommandName = "alpha";  
                        linkButton1.CommandArgument = "" + (char)(i) + j.ToString();  
     
                        footerItem.Controls.Add(linkButton1);  
                        footerItem.Controls.Add(lc);  
                    }  
                }  
     }  

    The code in the ItemCommand handler remains the same. Thus you should preserve the default pager and still have alphabetic pager below it.

    Greetings,
    Stephen
    the telerik team
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.