Anyone who had to work on the Pager localization for a RadGrid must have been confronted with two things:
This is a litle bit anoying, just because Telerik has given us the habit of extreme ease and flexibility, with a lot of properties that are customizable immediateley. But hopefully, accessing the advanced pager items (and localizing them) is simple and well documented (see the URL above.)
But something was missing. The "of" label as used in "Page x of y" is just not documented! After a litle investigation, it was rather easy to discover it, but the thing is that this Label doesn't contain only the word "of" but the page count as well ("of x" embedded in the same Label!)
To fully localize the advanced pager for the RadGrid, and until Telerik gives us the missing properties that would allow us to localize it very easilly, here is the code that can be used (just a sample):
I just hope that this post helps at least one person out there :)
Francois
- The advanced pager cannot be localized as easily as the other styles of pagers for the RadGrid : there is no PagerStyle item property that you can set in your aspx file to localize the Labels and Buttons of the advanced pager (like "PagerTextFormat" or "PageSizeLabelText").
- You have to access the elements of the advanced pager as described in the following page: http://www.telerik.com/help/aspnet-ajax/grdaccessingdefaultpagerbuttons.html
This is a litle bit anoying, just because Telerik has given us the habit of extreme ease and flexibility, with a lot of properties that are customizable immediateley. But hopefully, accessing the advanced pager items (and localizing them) is simple and well documented (see the URL above.)
But something was missing. The "of" label as used in "Page x of y" is just not documented! After a litle investigation, it was rather easy to discover it, but the thing is that this Label doesn't contain only the word "of" but the page count as well ("of x" embedded in the same Label!)
To fully localize the advanced pager for the RadGrid, and until Telerik gives us the missing properties that would allow us to localize it very easilly, here is the code that can be used (just a sample):
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
//Is it a GridPagerItem |
if (e.Item is GridPagerItem) |
{ |
// Localization for the pager has to happen here. |
Label lblPageSize = (Label)e.Item.FindControl("ChangePageSizeLabel"); |
lblPageSize.Text = "Page size"; |
Label gotoPage = (Label)e.Item.FindControl("GoToPageLabel"); |
gotoPage.Text = "Page"; |
Button gotoButton = (Button)e.Item.FindControl("GoToPageLinkButton"); |
gotoButton.Text = "Go"; |
Button changeButton = (Button)e.Item.FindControl("ChangePageSizeLinkButton"); |
changeButton.Text = "Change"; |
Label pageOfLabel = (Label)e.Item.FindControl("PageOfLabel"); |
pageOfLabel.Text = "of " + (((GridPagerItem)(e.Item))).Paging.PageCount; |
} |
} |
I just hope that this post helps at least one person out there :)
Francois