(version 19.1.20191.82)
A colleague wrote a custom `FilterCondition` a while ago, and when applied to a column, it automatically gets stored as part of the DisplayLayout. That is, if I later on call `grid.DisplayLayout.LoadFromXml()`, I get the same filter settings back. It appears they accomplished this by implementing `ISerializable` as well as having a constructor with `SerializationInfo` and `StreamingContext`.
I now wanted to do the same for a custom `GroupByComparer` and `GroupByEvaluator`. However, the same approach doesn't appear to work — when saving the layout, `ISerializable.GetObjectData` is never called.
Is there a way to store the GroupByComparer and/or GroupByEvaluator in the layout? Failing that, is there a more generalized way to add additional information to the layout (ideally, associated with the respective column)?
Hello Soren,
Thank you for your post. If we can save and load the custom 'filterCondition' then i was expecting GroupByComparer should also support that. In order to understand the scenario i set up a sample of UltraGrid with a GroupByComparer column, i save and load the layout using SaveAsXml and LoadFromXml and it working fine for me .I attached my sample here.
I am using version 19.2.
If this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.
Please let me know if I can provide any further assistance.
Sincerely,
Divya Jain
InfragisticsSample.zip
Hello Divya,
Thanks for the quick response. I think your test case demonstrates what I'm trying to solve:
1) run the code unmodified. Notice that the groups are sorted Col2Row3, Col2Row4, Col2Row2, Col2Row1, as the custom comparer does. Click Save.
2) exit the app.
3) comment out lines 92 and 93 (the last two lines in the constructor) such that Col2 is no longer a GroupBy column, and the comparer is no longer assigned:
//this.ultraGrid1.DisplayLayout.Bands[0].SortedColumns.Add("Col2", true, true);
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["Col2"].GroupByComparer = new GroupByComparer("Col1", "Sum");
4) run the app again. There's no grouping now, as expected.
5) Click Load, and click the column in the GroupBy area to make the sorting descending again. The groups are now sorted Col2Row4, Col2Row3, Col2Row2, ColRow1.
That is, clicking Load did restore that I wanted the list grouped by Col2, but it did not restore that I wanted to use a custom GroupByComparer. Looking at the DisplayLayout XML file suggests that this information isn't serialized at all.
The goal here is to store as much information as possible about the user's layout settings, including in this case details like what kind of GroupByComparer they used. (This is useful because the user can then switch between different layouts, which each come with their palette of settings.)
I hope that clarifies my question. The equivalent issue occurs with a GroupByEvaluator.
Thanks again,
Sören Kuklau