Hello,
How can i set the format of the number to not display the commas? I don't see a format property.
thanks
tom
Hi Tom,
Allmost all aspects of format come from NumberFormatInfo class (which is a member of CultureInfo). Among other properties it has XxxxGroupSizes. The Xxx will depend on class of editor: Currency/Numeric/Percent. In order to modify that, you should create an instance of that class, set desired properties and assign it to NumberFormat property of WebNumericEdit. To remove group/thousand separators you may try to use something like [1000] (first group with large number). That can be done anywhere in codes, for example, within Page.OnLoad event.
Installation also provides few samples for custom cultures and formats.
Hi Viktor,
I'm using NetAdvantage 9.2 ASP.NET AJAX CLR3x (Infragistics35.Web.v9.2) WebNumericEditor control.
which doesn't provide NumberFormat property. and I want to disable comma.
can you help me out on this how to set NumberFormat property.
here is my code.
<%@ Register Assembly="Infragistics35.Web.v9.2, Version=9.2.20092.1003, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.Web.UI.EditorControls" TagPrefix="ig" %>
<ig:WebNumericEditor ID="WebNumericEditor1" MaxLength="10" DataMode="Ulong" MinDecimalPlaces="0" MaxDecimalPlaces="0" runat="server" />
Thanks,
Rahul
Here is a reusable method I wrote to disable the commas and decimal points. (sorry it's not C#)
''' <summary> ''' Pass is a WebNumericEditor control and this method will prevent it from displaying commas and decimal points. ''' </summary> ''' <param name="editor"></param> ''' <remarks></remarks> Private Sub WebNumericEditorRemoveCommas(ByVal editor As Infragistics.Web.UI.EditorControls.WebNumericEditor) Dim ci As System.Globalization.CultureInfo = System.Globalization.CultureInfo.CreateSpecificCulture("en-US") ci.NumberFormat.NumberGroupSizes = {0} ci.NumberFormat.NumberDecimalSeparator = "," ci.NumberFormat.NumberGroupSeparator = "." editor.Culture = ci End Sub
My problem is I want comma, but they don't display. I'm using a WebDataGrid with a numeric editor provider:
Public
Sub WdgEditorInteger(ByVal wdg As WebDataGrid, ByVal FieldKey As String)
Dim NumericEditor As New NumericEditorProvider
NumericEditor.ID =
"NumericEditor"
wdg.EditorProviders.Add(NumericEditor)
Dim columnSetting As New EditingColumnSetting
columnSetting.ColumnKey = FieldKey
NumericEditor.GetEditor.ID =
NumericEditor.EditorControl.StyleSetName =
"Default"
columnSetting.EditorID = NumericEditor.ID
wdg.Behaviors.EditingCore.Behaviors.CellEditing.ColumnSettings.Add(columnSetting)
With NumericEditor.EditorControl
.ValueInt =
True
'No comma's show in the grid with or without the following lines:
Dim ci As Globalization.CultureInfo = Threading.Thread.CurrentThread.CurrentCulture
NumericEditor.EditorControl.Culture =
New Globalization.CultureInfo(ci.Name)
NumericEditor.EditorControl.Culture.NumberFormat.NumberGroupSeparator =
","
End With
wdg.Rows(0).Items.FindItemByKey(FieldKey).Column.Header.CssClass =
"wdgHeaderRightAlign"
End Sub
Hi thp,
The thousand/group separators are used by WebNumericEditor only in not-focus state. While cell-editing WebNumericEditor always has focus, therefore, possible custom value for that property does not change visible format of grid-editor.
If you refer to numeric strings, which appear in grid columns, then format of those strings is defined by default javascript formatting or by ScriptManager. I think, that if application will enable EnableScriptGlobalization property of ScriptManager, then strings will appear differently for different cultures.
It doesn't have a comma separator either in or out of focus. Should the WebNumericEditor display commas or do I have to set the format property of the column? My goal is to be able to autogenerate the columns using a sqldatasource and do the formatting in codebehind but haven't found code samples to do this and not sure if what I'm trying to do is even possible. With ultragrids, I've defined the columns in the HTML markup but this is very time consuming and I'm hoping to reduce the amount of effort.
I think the bottom line is can you format a column that is autogenerated from sqldatasource? The only thing I can find is
wdg.Rows(0).Items.FindItemByKey(FieldName).Column.FormatFieldMethod but can't find a shred of documentation on how to use it or even if I'm on the right track.
Thanks for your help,
thp
Hi thp.
Once you get to the Column object, you need to typecast it as BoundDataField, then access the DataFormatString method. Set this to something like {0:n} to display numbers. I believe this should take form the page's format/culture.
regards,David Young