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

Formatting PagerStyle to Include Comma Separators

3 Answers 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erin
Top achievements
Rank 1
Erin asked on 20 Jun 2012, 03:11 PM
I am working on a project that involves thousands of entries, so that when the Grid loads the Pager text in the lower right corner might display something like "Entries 1 to 20 of 10000000."  Is it possible to add comma separators to those numbers to make them more readable, such as "10,000,000" instead of "10000000"?  I have seen methods of introducing commas within the C# code, but in this case I am using something like PagerTextFormat="{4} Entries {2} to {3} of {5}" which appears to be sent through a hidden String.Format before displaying.  If there isn't a built-in way to set the comma formatting, is it possible to access the text after the values have been inserted into the {2}, {3}, and {5}, in order to insert commas?
Thank you!

3 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 21 Jun 2012, 01:43 PM
Hi Erin,

Please try the following approach:
<PagerStyle PagerTextFormat="{4} {1} Pages Total. Showing items {2} to {3} of {5:0,0} total." />

For additional information on formatting numeric values, please refer to the following article:
 Custom Numeric Format Strings

Greetings,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Erin
Top achievements
Rank 1
answered on 21 Jun 2012, 02:05 PM
Thank you for your response!

I had actually gone ahead and done this in the aspx.cs file, like this:
string strRows = (e.Item as GridPagerItem).Paging.DataSourceCount.ToString("#,##0");
string strPages = MyRadGrid.PageCount.ToString("#,##0");
MyRadGrid.PagerStyle.PagerTextFormat = "{4} " + strRows + " items in " + strPages + " pages";

But your way is much more elegant. 
Is there a reference from Telerik on how you can format variables like this?  Is something like this, from the msdn composite formatting examples, possible within the xml?

string myName = "Fred";
Console.WriteLine(String.Format("Name = {0}, hours = {1:hh}, minutes = {1:mm}",
      myName, DateTime.Now));
// Depending on the current time, the example displays output like the following:
//    Name = Fred, hours = 11, minutes = 30

Thanks
0
Eyup
Telerik team
answered on 22 Jun 2012, 01:44 PM
Hi Erin,

I am afraid this feature is not implemented. You could use regular System.String type formatting and the msdn articles for additional tips on formatting these string values.

Additionally, please check out the following help topic to understand in depth how to use pager item text formatting:
 Grid / Using PagerTextFormat

All the best,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Erin
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Erin
Top achievements
Rank 1
Share this question
or