Hello,
We have a grid with about 250 columns which displays multiple summary values per column and it takes between 5 and 10 seconds to simply display or hide those summary values. Is this normal simply to show/hide values?
Essentially I build the summaries up front, then when a user clicks on a button I do the following. Is this the best way to show/hide lots of summaries at once?
private bool showing = false;private void button1_Click(object sender, RoutedEventArgs e){ showing = !showing; foreach (var item in xamDataGrid1.FieldLayouts[0].SummaryDefinitions) { item.DisplayArea = ShowSummaryRow(showing); }}
private static SummaryDisplayAreas ShowSummaryRow(bool show){ return show ? (SummaryDisplayAreas.InGroupByRecords | SummaryDisplayAreas.BottomFixed | SummaryDisplayAreas.TopLevelOnly) : SummaryDisplayAreas.None;}
Thanks,Doug Rees
Ralph Lauren.
Hi Stefan,
Unfortunately using my sample project that I sent you it didnt make any performance improvement.
Regards,
Doug
Hello Doug,
I made some tests with “for” and “foreach” for iteration through the SummaryDefinitions and I noticed a little performance improvement, when I used “for”, because this way there are no new instances created for each item in the collection and less memory and time are needed, but with 250 columns, each one with 3 Summaries, I iterated trough them for 1.5 - 2 seconds.
Hope this helps you.
Thank you for your suggestion. The problem is that this hides or shows ALL of the grid's summaries and I need to do it selectively as the user can decide which ones to show or hide. (I know my code sample didnt include this ability - it was a simplified version)
Also, yes it is fast but the grid seems to think the summaries are still there as the area reserved for the summaries doesnt shink down when none are displayed until you resize the window, then it updates.
Im sure there is an appropriate refresh method to call here, but really without the ability to selectively hide/show individual summaries it possible for me to use your code.
Regards,Doug
Thank you for your post. I have been looking through it and I suggest you use the following code instead of the one you have provided, because it doesn’t iterate through all the SummaryDefinitions and there is no delay.
SummaryRecordPresenter srp = (SummaryRecordPresenter)Utilities.GetDescendantFromType(xamDataGrid1, typeof(SummaryRecordPresenter), true); if (srp.Visibility == System.Windows.Visibility.Visible) { srp.Visibility = System.Windows.Visibility.Collapsed; } else srp.Visibility = System.Windows.Visibility.Visible;
Please let me know if this helps you or you need further clarifications on this matter.
Looking forward for your reply.