Custom Alpha Paging for RadGrid

3 posts, 0 answers
  1. Vladimir Milev
    Vladimir Milev 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:

     
    Note: The depicted functionality is supported for RadControls for ASP .NET AJAX as demonstrated in this online example.

    PROJECT DESCRIPTION
    Enable custom alpha paging on the grid with multiple pages for single letter.
  2. Dhaval
    Dhaval 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. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    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