HiI am wondering about something that has to do with Field layout in the XamDataGrid.
I have an XamDataGrid. The ItemsSource is a buinding to an ObservableCollection of my class. Let's call it "MyClass".
If "FieldLayoutSettings" I have set AutoGenerateFields="False" because I have entered my selected Fields in DataGrid.FieldLayouts.
My problem:The data is fetched from the database, and the data type of some fields are "Decimal" (because it's defined as "NUMBER" in the Oracle database.
When the datatype is "Decimal", the grid place a rather annoying dollar sign in front if the value in the grid. I'd like to make this go away...
But how?
I tried to set the DataType property in the <Field> to: - DataType="{x:Type String}" - DataType="{x:Type System.String}" - DataType="{x:Type sys:String}" - DataType="String"...nothing works. All gives the error "The type reference cannot find a public type named 'String'".
Then I tried to change the <Field />" to <UnBoundField />. but still the same problem.
What's the deal with that dollar sign?I don't even have my culture settings set to US. I have a norwegian setup, so it should at least show "kr" (even if that also would be incorrect because it is only a notmal number)
- Mats MagnemKSD Software
Hello,
Just as an info message:
I'm also facing this "same problem". I'm currently trying to develop some grid-app where the columns and the rows are fully dynamiccally (but I will post a new thread for that)
But I also had the problem of decimal-types coming from the oracle DB (which are in my case just normal integer) --> but when you set the editType to string, you lose the correct sorting of those values (because string sorting <-> number sorting)
So in my case (where I "knew" that it are just integer) I set the edittype to System.int32
In other cases (real decimal-numbers), I set the type to System.Double instead of System.Decimal
Fred
Thanks!That was useful information, and I was able to solve my problem based on elements from that solution.
Thank you :-)
- Mats Magnem
Hello Mats,
This happens because the grid automatically generates a default XamCurrencyEditor for the decimal columns. In order to remove the currency symbol you can use one of the following approaches:
1. Change the Format or the Mask using custom Style for the XamCurrencyEditor and an EditorStyle property to set this style on the Field:
<igDP:Field Name="Decimal">
<igDP:Field.Settings>
<igDP:FieldSettings>
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamCurrencyEditor}">
<Setter Property="Format" Value=".###"/>
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
2. Another option is to change the data type of the Field using the EditAsType property in order to validate the decimal values as strings:
xmlns:sys="clr-namespace:System;assembly=mscorlib"
<igDP:FieldSettings EditAsType="{x:Type sys:String}"/>
Let me know if you have any questions.