Hello
We have XamDataGrid (assembly version 11.1.20111.2193).
For DateTime columns we are using following style:
<Style TargetType="{x:Type igEditors:XamMaskedEditor}" x:Key="DateCellStyle"> <Setter Property="Mask" Value="{}{date}" /> </Style>
... and settings:
field.DataType = typeof(DateTime?);
field.Settings.EditorStyle = (Style)((ResourceDictionary)resources["ModuleResources"])[styleName]; field.Settings.EditAsType = typeof(DateTime);
field.Settings.EditAsType = typeof(DateTime?);
The last line is crucial. It makes grid works incredibly slow (even for relatively small number of rows: 1000).
If I change that to the following:
field.Settings.EditAsType = typeof(DateTime); //not nullable!
It makes grid work as a charm! - performance is perfect. However, with nullable - performance is so bad that user is unable to work normally.
The reason I want it nullable is that, when value is null, in case Nullable - the content is empty.
If it's set as not nullable - there is default date as content 01.01.0001.
Question: If this is a bug (performance bug), or, if not, are there any other ways to handle "empty content" specs.
Hello,
I am glad that you have manage to solve your issue.
In case of future concerns please do not hesitate to contact us.
Sincerely,
Ekaterina
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support
Hello.
First of all - thanks for this effort!
I dug into your sample in order to see the result, and step by step I was converting it to mock my application. Finally I found the problem, and it seems to be in my code.
In converter, I had:
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) return string.Empty;
So for every nullable DateTime which was null, the actual value that went to the cell was actually string.Empty. And this is the root cause of the performance issue. (I've played around with this a bit, and this seems to be general performance problem, that, if type is different than "EditAsType" type, the performance is terrible.
This seems to be solved now. I don't know if the performance problem is XamDataGrid bug or expected hebaviour. Thanks anyway.
I have been looking into your issue and I tried to reproduce it, but however I did not manage to get the described behavior. I am sending you my sample in order for you to take a look and modify it if needed.
As to your second question, what you can do in order to set an empty cell is to use some mechanism that explicitly set the needed cell value to null. For example this could be a converter that convert a special cell’s value to null. However these approaches should be much slower that binding the grid to a nullable dataSource. I am adding 10 000 rows ( of type DateTime?) to my grid and the performance is the same if I add a normal DateTime.
I will be looking forward to have some feedback from you according the discussed topic.