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?
Do you have further questions?
Hi,
I'm afraid I'm still finding it very difficult to follow you.
dynacon8 said: 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.
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.
I think I am with you up to this point.
dynacon8 said: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.
Here's where you lost me. You are loading the previously saved layout into a grid that has different column names?
And where did B2 come from? You only mentioned A1 and B1.
dynacon8 said: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?
There is no way to "mark" any settings as default.
dynacon8 said: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?
What do you mean by "deserialization of empty grid layout"? You are loading an empty layout? Empty in what sense?
Any layout that you save is tightly tight to the data structure that the grid had when you saved it. I think that maybe you are trying to save a layout and then load that layout into a grid that has a different data structure. This is not the intended use of the load and save feature and I would not be surprised if you got unpredictable results.
Problem:
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?
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.