We have a XamDataGrid with 100 columns and 4000 rows. We made a column chooser control that allows the user to hide and show columns. Hiding a column by setting the Field.Visibility = Collapsed takes several seconds on a fast machine and over 5 seconds on a slower one. if we set the ColMaxWidth = 0 instead, then it's much faster, but that's not the same as making the column invisible. We also tried removing the column from the FieldLayout, but that was just as slow. Any suggestions on making column hiding and showing faster? I have a simple test application that binds to a DataTable that shows the issue if you need it.
Hello,
Can you please provide the sample that you have. It would be helpful for us to experience the same issue.
Thanks,
Alex.
I've attached the sample code.
Thank you for the sample. Indeed there is bigger delay when changing the Visibility property.
The only thing I can think of right now, is setting also AllowLabelVirtualization and AllowCellVirtualization properties to false, which ,at least on my machine, reduced slightly the delay.
I am going to bring that up to the Engineering team to see if there is a way to reduce this (however the number of fields is above average) and follow up here.
Regards,
The main reason for the slow performance, is that the Fields you are creating does not have EditAsType property set and therefore virtualization for them is not allowed. When you create them in code, set the DataType and you will notice improvement in performance:
_layout.Fields.Add(new Field()
{
Name = col.ColumnName,
Column= colIndex++,
Settings = new FieldSettings() { CellWidth = 100, EditAsType=typeof(string) }
});
This virtualization will reduce the number of elements that are recreated and released when hiding/showing fields.
Just as a side note, we noticed that you have set the RecordContainerGenerationMode to PreLoad. This means that DataRecordPresenters are generated for all the 4000 records, not just for the ones in view (4000 DataRecordPresenters instead of 20 or 25). Unless you have some explicit reason for this, we suggest using the other options - LazyLoad, Virtualize).
Please let me know when you have the chance to test this.