This question is locked. New answers and comments are not allowed.
I'm using .Format("{0:Nn_number_of_decimals}") to format my numeric columns in a grid. If format is {0:N}, it works perfectly. It shows symbol separator depending on cultureInfo and two decimal places correctly. But if the format of the column is {0:N0} or {0:N3} for example, because the column has no decimal positions or has 3 decimal places, it doesn't work.
CustomFormatRegEx considers N0 as a custom Format.
N1, N2, N3 and so on are considered as Not Custom formats but it doesn't take into account de number of decimal positions.
Wouldn't $t.formatNumber function in telerik.common.js be something like this?
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx#NFormatString
CustomFormatRegEx considers N0 as a custom Format.
N1, N2, N3 and so on are considered as Not Custom formats but it doesn't take into account de number of decimal positions.
Wouldn't $t.formatNumber function in telerik.common.js be something like this?
switch (format.toLowerCase()) {
case 'd':
return Math.round(number).toString();
case 'c':
type = 'currency'; break;
case 'n': type = 'numeric'; break;
// added code: up to 9 decimal places.
case 'n0':
case 'n1':
case 'n2':
case 'n3':
case 'n4':
case 'n5':
case 'n6':
case 'n7':
case 'n8':
case 'n9':
type = 'numeric'; if (!digits) digits = format.substring(1); break;
// end added code
case 'p':
type = 'percent';
if (!isTextBox) number = Math.abs(number) * 100;
break;
default:
return number.toString();
}
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx#NFormatString
Sample of grid:
.Columns(Sub(columns) columns.AutoGenerate(False) columns.Bound(Function(bound) bound.ProductId()).Width(80) columns.Bound(Function(bound) bound.Description()).Width(300) If ViewBag.LoadExpirationDate Then columns.Bound(Function(bound) bound.ExpirationDate()).Width(100).Format("{0:d}").EditorTemplateName("Date") columns.Bound(Function(bound) bound.Price()).Width(150).Format("{0:N3}").EditorTemplateName("Currency") columns.Bound(Function(bound) bound.Quantity()).Width(150).Format("{0:N0}") End If End Sub) _ .DataBinding(Sub(dataBinding) dataBinding.Ajax() _ .OperationMode(GridOperationMode.Client) _ .Select("LoadData", "Home") _ .Update("Save_Batch", "Home") End Sub) _.
Do you have any solution?