I use XamDataGrid to display results of execution of randomly created SQL “SELECT” statements (via DataTable.DefaultView). Neither number of fields being retrieved nor their types are known at design time.
Please advise how to setup XamDataGrid to avoid these problems:1. Dollar sign prefixes all decimal values – need to get rid of dollar sign as those values are NOT currency2. Message “A first chance exception of type 'System.NullReferenceException' occurred in Infragistics3.Wpf.Editors.v9.1.dll” is added every time I scroll the grid. Due to this inner exception throwing the scrolling makes a tiny pause after every line. This occurs even when the solution is compiled in ‘Release’ configuration.
Here is XAML code I’m using:<infragisticsGrid:XamDataGrid x:Name="PART_XamDataGrid" DataSource="{Binding}" ScrollingMode="Immediate" RecordLoadMode="PreloadRecords" RecordContainerGenerationMode="PreLoad">
<infragisticsGrid:XamDataGrid.FieldSettings> <infragisticsGrid:FieldSettings AllowRecordFiltering="False" AllowEdit="False" CellClickAction="SelectRecord" EditorType="{x:Type infragisticsEditors:XamNumericEditor}" LabelClickAction="SortByOneFieldOnly" LabelTextWrapping="WrapWithOverflow" AllowSummaries="true" SummaryUIType="SingleSelectForNumericsOnly" SummaryDisplayArea="Top" LabelTextAlignment="Center"> </infragisticsGrid:FieldSettings> </infragisticsGrid:XamDataGrid.FieldSettings>
<infragisticsGrid:XamDataGrid.FieldLayoutSettings> <infragisticsGrid:FieldLayoutSettings AutoGenerateFields="True" AllowFieldMoving="Default" LabelLocation="SeparateHeader" HighlightAlternateRecords="True" RecordSelectorLocation="Default" AutoArrangeCells="LeftToRight" SelectionTypeRecord="Single" DataRecordSizingMode="SizedToContentAndIndividuallySizable"> </infragisticsGrid:FieldLayoutSettings> </infragisticsGrid:XamDataGrid.FieldLayoutSettings>
<infragisticsGrid:XamDataGrid.ViewSettings> <infragisticsGrid:GridViewSettings Orientation="Vertical" /> </infragisticsGrid:XamDataGrid.ViewSettings></infragisticsGrid:XamDataGrid>
Thank you,
Eugene
Hello Eugene,
Regarding the currency symbol, this is because the default XamEditor for a field of type Decimal in the XamDataGrid is xamCurrencyEditor and therefore it shows the currency symbol of the current culture. One way to avoid this is to register another XamEditor to the fields of type Decimal. This is done by calling the calling the static RegisterDefaultEditorForType method of the ValueEditor Class. Please take a look at this post to see how to do this or just let me know if you have questions on this.
Regarding the exception, first thing that comes in my mind is that it is coming from this line:
EditorType="{x:Type infragisticsEditors:XamNumericEditor}"
Once you have registered a new XamEditor for the Decimal value type, you will not be needing this.
Test this and give me a feedback if the exception is gone and whether you have managed to register the new ValueEditor.
Please note, that using PreLoad virtualization techniques can have a performance impact on the responsiveness and memory usage of the application if you have many records - in such case LazyLoad/Virtualize would be more appropriate choice.
Regards,
Alex.
Alex, thank you for your advise. Unfortunately it did not help. Here is what happens:
When I execute:
ValueEditor.RegisterDefaultEditorForType( typeof( Decimal ), typeof( XamNumericEditor ), true );
Dollar sign re-appears.
ValueEditor.RegisterDefaultEditorForType( typeof( Decimal ), typeof( XamTextEditor), true );
Dollar sign disappears but textual sort order is applied when I click column’s header (i. e.: 1, 10, 2, 3)
FYI: I have installed the latest hot fix. “System.NullReferenceException” is gone after I had removed “EditorType” from XAML.
Any other suggestions, please?
Thanks!
In this case, you can Register a mask for the Currency Editor:
XamCurrencyEditor.RegisterDefaultMaskForType(typeof(decimal), "{double:-5.5}");
or
XamCurrencyEditor.RegisterDefaultMaskForType(typeof(decimal), "nnnnn.nn");
You can see other options for masks here.