Hi,
I want to serialize XamPivotGrid layout as an XML stream and save it into database. Later on user could load this layout from database and display his pivot grid based on the saved layout. It seems that there is no associated methods for serializing PivotLayout as XML and deserializing the XML to PivotLayout object. I tried to use normal serialization but got some exceptions. Here is what I got. Can you please let me know when this function be added to XamPivotGrid or do you have any suggestions to work around this issue?
Thanks for your help. Our users definitely need this function be implemented in our product.
Joseph
=====================================================================
Case #1: Serialize PivotLayout
XmlSerializer serializer = new XmlSerializer(typeof(PivotGridLayout));
Got exception:
{"Infragistics.Controls.Grids.PivotGridLayout cannot be serialized because it does not have a parameterless constructor."}
----------------------------------------------------
Case #2: Serialize XamPivotGrid
XmlSerializer
serializer = new XmlSerializer(typeof(XamPivotGrid));
Got Exception:
There was an error reflecting type 'Infragistics.Controls.Grids.XamPivotGrid'.{"Cannot serialize member 'System.Windows.Input.InputBinding.Command' of type 'System.Windows.Input.ICommand', see inner exception for more details."}{"Cannot serialize member System.Windows.Input.InputBinding.Command of type System.Windows.Input.ICommand because it is an interface."}
Hello,
Please take a look at this sample. It shows how to save the layout of the pivotgrid to memory, how to serialize it to an xml file and how to binary serialize it to a database. It is tested to work both with the FlatDataSource and XMLADataSource, and the controls from the 10.3 release.
In a few words, the PivotGrid does not support serialization out-of-the-box. What you need to do is create your own class that will hold all the important data from the PivotGrid in order to recreate the layout. In the sample the class that does that is called SavedPivotGridView. All of its properties are of primitive types and thus it is easily serializable.
All the best,
Atanas Dyulgerov
Hi, I followed the example in the sample you posted, but when I load a saved layout into the grid, it doesn't preserve the order of the columns or rows, it puts them in alphabetical order. For example, if define the hierarchy as Year -> Month -> Day, when I load that layout back, it becomes Day -> Month -> Year. Do you know what could be causing this?
I found the problem, the Fill method doesn't take the order of the row, column, or filter hierarchies into account when it reconstructs the view.