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 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
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,
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.
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
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