Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Layout not the same following SaveAsXml/LoadFromXml
posted

Hi,

2008 volume 3 UltraGrid.

An earlier thread detailed a problem with the VisiblePosition property on a grid column not updating when the column's visible position within a grid is changed.  See the post "VisiblePosition of UltraWinGrid Columns Not Updating".

I have the same situation.  I have some code to save and restore the grid layout that relies on the VisiblePosition property.  The property doesn't seem to work so my code fails to lay the columns out correctly during deserialisation.

Here's some background:

I have an intialisation routine for the grid.  The initialisation routine does all the usual things including setting up a summary block to appear at the bottom of the grid and specifying the format of the data to appear on a row when it is a group-by row.

My serialisation code merely iterated the list of columns and saved and restored some of the attributes within - Key, Hidden, Width, VisiblePosition, IsGroupByColumn & SortIndicator.  There was no special code to save or restore the summary block or the group-by row information.


To overcome the problem with VisiblePosition, I've followed the advice in the earlier post and adapted my code to use UltraGrid.DisplayLayout.SaveToXml and UltraGrid.DisplayLayout.LoadFromXml.  This solves the problem.  Yipee!  BUT - it introduces two other problems that weren't present in my original implementation.


1. Generally speaking, if a column is selected for 'group-by', the text on each of the expandable rows contains the name of the column followed by the column value, the number of items in the group and some other information controlled by the programmer (see the note regarding initialisation above).

E.g. "+Boundary : D173DEBLO (1 item) <other information>" where the Boundary column is a group-by column and D173DEBLO is one of the values for that column.

With my old serialisation code, this format was mantained across the save/restore.

Using the DisplayLayout Save/Load methods, the group-by settings are maintained but the group-by rows are now missing the additional information, e.g. "+Boundary : D173DEBLO (1 item)". <other information> is missing.

2. Underneath the rows for the whole grid with no group-by or underneath the child-rows for each group-by row I had arranged for summary information to be displayed.  This summary information layout was maintained across my save/restore, but the summaries are missing following the DisplayLayout Save/Load.

I have verified that when re-loading a grid from Xml, the grid is first initialised and then the LoadFromXml method is called on the DisplayLayout member.

Is it expected behaviour that these two formatting setups are not saved and restored by the SaveToXml and LoadFromXml methods?
I was expecting that the load and save methods on the DisplayLayout member would save and load the complete layout, not just certain parts of it.
Can you offer any guidance as to what is considered 'best practice' regarding saving the layout of a grid and re-loading it later?

Regards
David Razzetti

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    jumpjet said:

    1. Generally speaking, if a column is selected for 'group-by', the text on each of the expandable rows contains the name of the column followed by the column value, the number of items in the group and some other information controlled by the programmer (see the note regarding initialisation above).

    E.g. "+Boundary : D173DEBLO (1 item) <other information>" where the Boundary column is a group-by column and D173DEBLO is one of the values for that column.

    With my old serialisation code, this format was mantained across the save/restore.

    Using the DisplayLayout Save/Load methods, the group-by settings are maintained but the group-by rows are now missing the additional information, e.g. "+Boundary : D173DEBLO (1 item)". <other information> is missing.

    What is the "<other information>" and where is it coming from?

    The text of the GroupbyRows is determined by the GroupByRowDescriptionMask property. So perhaps you are setting this property in your code somewhere either before or after the saving and loading of the layout and it's somehow getting out of synch. This property setting should be saved as part of the layout, assuming you are passing in the correct flags to save grouping.

    Another possible way to change the text of the GroupByRow is to use the InitializeGroupByRow event. So if you are handling that event, check to make sure you are not stepping on some other settings.

    Still a third option is that the "other information" is a summary or multiple summaries. Perhaps you are not including summaries in your save or load method calls.

    jumpjet said:

    2. Underneath the rows for the whole grid with no group-by or underneath the child-rows for each group-by row I had arranged for summary information to be displayed.  This summary information layout was maintained across my save/restore, but the summaries are missing following the DisplayLayout Save/Load.

    I have verified that when re-loading a grid from Xml, the grid is first initialised and then the LoadFromXml method is called on the DisplayLayout member.

    Is it expected behaviour that these two formatting setups are not saved and restored by the SaveToXml and LoadFromXml methods?
    I was expecting that the load and save methods on the DisplayLayout member would save and load the complete layout, not just certain parts of it.
    Can you offer any guidance as to what is considered 'best practice' regarding saving the layout of a grid and re-loading it later?

    It's starting to sounds like your loading or saving of the layout simply does not include the summaries and that this is the information that is missing from the GroupByRows. The only way that should happen is if you are passing in flags to the Save or Load methods and excluding the summary information.

Children