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

Access for Custom Pager Controls ASP.NET AJAX control

3 Answers 142 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Drew
Top achievements
Rank 1
Drew asked on 02 Jun 2008, 04:47 PM
My team is currently migrating to the ASP.NET AJAX controls.

We are currently experiencing an issue with the RadGrid's paging.  We would like to continue with our current functionality moving forward.

We have a paging item that we have added to give users access to the first page of the paging directly.  To accomplish this, there is a LinkButton added directly in front of the "previous page" button.

As an example:


protected void SearchGrid_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridPagerItem)
{
//These control the footer of the grid where the page change can be displayed 
Label ChangePageSizeLabel = (Label)e.Item.FindControl("ChangePageSizeLabel"); 
 
//Created a "First Page" button
LinkButton btnFirst = new LinkButton(); 
btnFirst.Text = "«"
btnFirst.CommandName = "Page"
btnFirst.CommandArgument = "First"
 
//Add the button to the control 
ChangePageSizeLabel.Parent.Parent.Controls.AddAt(0, btnFirst);
}
}

After the update, this isn't adding the button back in the correct position.  It looks as though getting a reference to a label isn't going to work, as the paging is seen contained with the PagerLeft_Office2007 class.

How can I accomplish this with the update?  Also, I am aware of the Pager Template, but I do not see a reason to implement one for this minor update.  If it at all possible I would like to simply modify this managed code.

Thanks!

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 04 Jun 2008, 02:54 PM
Hello Drew,

You can try something similar to:

void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridPagerItem) 
        { 
            GridPagerItem item = (GridPagerItem)e.Item; 
            LinkButton firstBtn = new LinkButton(); 
            firstBtn.Text = "1 Page"
            item.PagerContentCell.Controls.AddAt(0, firstBtn); 
        } 
    } 

This should add your LinkButton in front of the other controls in the pager.

Best regards,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Drew
Top achievements
Rank 1
answered on 05 Jun 2008, 03:25 PM
Veli,

Thank you for the fast response.

I have tried implementing the update as you have mentioned, with slightly different results than expected.  The LinkButton is now displaying on what looks to be the first "row" of the paging panel.  The AddAt appears to be shifting all of the controls, whereas the goal is for this to display within the paging already there.

It has shifted down the text for "Change page: (indexes)       Change page: (textbox) Go       Displaying page 1 of 1, items....", so now it is on its own line.

I would like to have the custom LinkButton be inserted right before the arrow that would page back to a previous page.

Here is another attempt to help clarify as I feel I haven't done a sufficient job in this area.  The single line of paging would look like this on the very left side of the panel:
Change page: [Custom Link Button we are creating] [Default paging previous page button] (indexes for paging) [Default paging forward page button]

I hope this has helped clarify as I feel I am close to the solution with your help. 

Thank you!
0
Veli
Telerik team
answered on 06 Jun 2008, 09:56 AM
Hello Drew,

Thanks for the clarificiation. This should work for you:

void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridPagerItem) 
        { 
            GridPagerItem item = (GridPagerItem)e.Item; 
            LinkButton firstBtn = new LinkButton(); 
            firstBtn.Text = "1 Page"
            Panel panel1 = (Panel)item.PagerContentCell.Controls[0]; 
            panel1.Controls.AddAt(1, firstBtn); 
        }  
    } 

The PagerContentCell has 2 panel controls, 1 for the pager navigation and 1 for the display information. You need to get the first one, and add your button to the second place (item index 1), after the "Change page" label.

Greetings,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Drew
Top achievements
Rank 1
Answers by
Veli
Telerik team
Drew
Top achievements
Rank 1
Share this question
or