I'm trying to serialize grid layout. My intention is to keep user column filters, sorting, grouping (outlook groupby) and column widths for windows of same type (MDI).
What I try to do is: ultraGrid.DisplayLayout.Save(memStream, PropertyCategories.ColumnFilters | PropertyCategories.SortedColumns | PropertyCategories.Groups) and it works almost fine.
Many of my grid properties are initialized at runtime - groups (row layouts), column header text, grouping, etc. I noticed that in some cases I loose column headers text and couple of other things set dynamically during form loads (probably because I deserialize layout of empty window into window that already has some data)
I found Mike's post that says : "... the saved layout only includes things that have actually changed - but by that I mean things that have changed from the default values in the grid - not neccessarily things that the user changed...", so I understand, that things done during window initalization (at runtime, not design time) will be serialized and deserialized as if user did this?
Is there a way I could tell to grid that "keep changes as default, and from now on track changes to be serialized" to distinguish user layout operations from "legal" ones?
Hi,
I'm not sure I understand what you are asking.
Perhaps what you need to do is save the layout of your grid at a point before the user makes any changes. That way you have a baseline that you would load into the grid that would re-set the user back to the defaults.
Of course, the layout you saved might not include everything. So what you would do is call grid.DisplayLayout.Reset first, then load your layout. That way everything is reset to the default values and you load your defaults into a clean layout.
Problem:
I start window with dynamically created columns A1 and A2, they are in column groups G1 and G2.
When window is initializing I set column headers to be "A1 text" and "A2 text". Then user does some sorting/outlook groupby/filtering. When window closes I serialize grid layout with options PropertyCategories.ColumnFilters | PropertyCategories.SortedColumns.
Other window of same type is loaded, groups are the same, columns are now "A1" and "B1", headers "A1 text", "B1 text". I deserialize layout and expect to have desrialized settings for column A1 and no changes to column B2. Instead header text of B2 is cleared. Should be - user made no changes to headers, so their settings should not be serialized.
Correct me if I'm wrong - If I could mark settings as "default" at some point, grid would not notice changes and would not serialize them?
EDIT - setting DataColumn.Caption to be the same as Header.Caption does the trick - text is not overwriten during deserialization.
Still having problems with cardview layout blown away with deserialization of empty grid layout. Why does it interfere with anything else than just filters and sort as in options?