Hi, In my proect I have to save the pivot grid view in an xml file and load it from the xml. I make it like the following example.
https://es.infragistics.com/samples/silverlight/pivot-grid/#/save-and-load-views
There is only one diffrence that I take the XML information from another page with the URL. And read it like following lines.
SavedPivotGridView XMLSerializedView = new SavedPivotGridView();
XmlSerializer serializer = new XmlSerializer(typeof(SavedPivotGridView)); StringReader stringReader = new StringReader(QueryResult); XMLSerializedView = (SavedPivotGridView)serializer.Deserialize(stringReader);
XMLSerializedView.Fill(this.pivotGrid);
The problem is that the levels are not getting expanded when the load method run. I think the problem is about to SavedPivotGridView class. But I could not find. Any suggestion?
Hi tbabur!
We are currently preparing a new sample where an improved approach is used in saving/loading pivot grid views. It will be published with the next service release, which is planned to ship in about two weeks. I will write to you here as soon the sample is published.
If it is not acceptable for you to wait until then, could you provide some more details on the issue you are experiencing (e.g. what datasource you are using etc.) or maybe attach a sample where it could be reproduced?
Regards,
Philip
I can wait about two weeks. But I do not know I do something wrong or it is related to a new version?
So here is my code that almost same the above link. I call the SavedPivotGridView class methods from these methods.
public void SaveQuery() { XMLSerializedView = new SavedPivotGridView(); XMLSerializedView.SaveView(pivotGrid);
XmlSerializer serializer = new XmlSerializer(typeof(SavedPivotGridView)); MemoryStream memoryStream = new MemoryStream(); serializer.Serialize(memoryStream, XMLSerializedView);
SaveFileDialog saveFileDialog = new SaveFileDialog() { DefaultExt = "xml", Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*", FilterIndex = 1 };
if (saveFileDialog.ShowDialog() == true) { using (Stream stream = saveFileDialog.OpenFile()) { byte[] bytes = memoryStream.ToArray(); stream.Write(bytes, 0, bytes.Length); stream.Close(); memoryStream.Close(); } } }
public void LoadQuery() {
XmlSerializer serializer = new XmlSerializer(typeof(SavedPivotGridView));
OpenFileDialog openFileDialog = new OpenFileDialog() { Multiselect = false, Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*", FilterIndex = 1 };
bool? result = openFileDialog.ShowDialog();
if (result != null && result == true) { XMLSerializedView = (SavedPivotGridView)serializer.Deserialize(openFileDialog.File.OpenRead()); XMLSerializedView.Fill(pivotGrid); } }
I tried your code and it seems to be working normally - I was able to serialize and then deserialize a view of the pivot grid where some members were expanded. I am attaching the sample in case you want to try it yourself.
In your case make sure that you wait enough time when restoring a serialized view - if multiple hierarchies have to be loaded/filtered and if the connection/cube is slow this may be a time consuming job. Then for some time it would appear that no expansion is happening. Could you check if this is what is happening to you?
We are using diffrent SavedPivotGridView classes. I take this class from 2011.1 version of Silverlight DV. And it is not checking the loaded hierarchies.
Now, I got examine your sample and it worked for my data source. Thank you.
Can anyone give some insight on the "new and improved" sample and how it will function? I'm currently in the decision process on whether or not this control will suit the requirements we're looking for. By function I mean, will there be any built in code to save the views to a database / XML file without any intensive custom code required?
Thanks!
Thanks for your response. The description you gave makes more than enough sense to wait for the next service release.
Hello JHaynes,
The new sample I mentioned in the previous post will enable you to save and restore the exact state of a pivot grid. The class used for storing the state information is serializable and exporting to xml comes down to calling a single method that will do all the needed work. Restoring a view works in a similar manner. If you need it, we could also provide you with some sample code for saving views to a database. Once a view is saved, it can be restored to any pivot grid that uses the same datasource (meaning a view can be accessed by multiple users if needed).
In a nutshell, you will just be required to decide exactly how to use this functionality in your application.
If you need more details or if you have any further questions we would be glad to answer them.