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

Changing the "X items in Y pages" label in the pager row

3 Answers 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 23 Nov 2011, 04:26 PM
On the bottom right hand side of the pager is the text that says, for example, "100 records in 4 pages". What I would like to do is changes this to say 75 records in 3 pages even if there are 100 records. The reason I want to do such an odd thing is that in some instances, there are 100 records, but 75 of them are parents, and 25 are children. I only want the parent records to be displayed in the "X records in Y pages" string. Is this possible?

I've tried the code in http://www.telerik.com/help/aspnet-ajax/grid-accessing-default-pager-buttons.html:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridPagerItem)
    {
        GridPagerItem item = e.Item as GridPagerItem;
        Label pageOfLabel = e.Item.FindControl("PageOfLabel") as Label;
        pageOfLabel.Text = "OF " + item.Paging.PageCount.ToString();
    }
}

When I run through the code, I get an exception - "Object reference not set to an instance of an object." - at the "pageOfLabel.Text..." line.

Thank you,
Scott

3 Answers, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 1
answered on 23 Nov 2011, 08:54 PM
Thanks for the links - they look very promising. I'm having one problem: When I try to compile, I'm getting an error that the library can't be found:

     The type or namespace name 'MRCResources' does not exist in the namespace 'Resources' (are you missing an assembly reference?)

I have this Telerik using statement in my code:

     using Telerik.Web.UI;

Which other using statement do I need?
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 24 Nov 2011, 06:30 AM
Hello,

protected void RadGrid1_PreRender(object sender, EventArgs e)
       {
          GridPagerItem pagerItem = (GridPagerItem)RadGrid1.MasterTableView.GetItems(GridItemType.Pager)[0];
          RadGrid1.PagerStyle.PagerTextFormat = "{4} " + "MYPage" + " {0} " + "MYOf" + " {1} , " + "MYItems" + " {2} " + "MYTo" + " {3} " + "MYOf" + " {5}";
          RadGrid1.Rebind();
       }


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Scott
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Scott
Top achievements
Rank 1
Share this question
or