PivotGrid Serialization

Good day.

I noticed that the WPF version of the pivotgrid now has support for serialization/deserialization. Is this function planned to be added to the WindowsForms version as well?

If not is there any other way to save the structure of a pivot grid (row fields, col fields, filter fields, etc.) so that those settings can be saved and loaded via button clicks.

I would like to be able to manipulate data in a pivot grid, send the visual data from that grid to a chart and/or static gridcontrol, save the data for each control, and update those controls with new data, but with the same structure, similar to what the dashboard platform does but on a much, much smaller scale.

Thanks.

5 Replies

DK Dineshraj Kumar Syncfusion Team June 4, 2018 01:09 PM UTC

Hi Travis,   
  
Thanks for contacting Syncfusion Support,  
   
We have provided the support for serialize/deserialize the PivotGrid control in Windows Forms platform and it has been included in our main release Volume 2, 2018 which will be estimated to be available by this month of June.    
   
Regards,   
Dineshraj K.   



TC Travis Chambers June 26, 2018 02:00 PM UTC

Good day,

I have just tried out the serialization and deserialization of the pivotGridControl and it seems to be working great! However, when deserializing an automated dialogue box appears saying that the deserializing was successful. Is there a way to suppress this message? I do not want to have this generic message poping up each time the grid is deserialized.

Thanks.


TB Thirupathi Bala Krishnan Syncfusion Team June 27, 2018 12:04 PM UTC

Hi Travis, 

Thanks for the update. 

We have checked your requirement – “To suppress the message dialog while serialize/deserialize the PivotGrid control”. You can achieve this requirement by invoking the Serialize()/Deserialize() method in the button click event handler. 

Please refer the below code sample. 

# Form1.cs 
 
        private void buttonAdv1_Click(object sender, EventArgs e) 
        { 
            SaveFileDialog sfv = new SaveFileDialog(); 
            sfv.FileName = "Sample"; 
            sfv.DefaultExt = ".xml"; 
            sfv.Filter = "(*.xml)|*.xml"; 
            if (sfv.ShowDialog() == DialogResult.OK) 
            { 
                using (var sw = new StreamWriter(sfv.FileName)) 
                { 
                    SerializationController serializationController = new SerializationController(this.pivotGridControl1); 
                    serializationController.Serialize(sw.BaseStream, serialization()); 
                } 
            } 
        } 

        private void buttonAdv2_Click(object sender, EventArgs e) 
        { 
            OpenFileDialog ofd = new OpenFileDialog(); 
            ofd.DefaultExt = ".xml"; 
            ofd.Filter = "(*.xml)|*.xml"; 

            if (ofd.ShowDialog() == DialogResult.OK) 
            { 
                using (var sw = new StreamReader(ofd.FileName)) 
                { 
                    SerializationController serializationController = new SerializationController(this.pivotGridControl1); 
                    serializationController.Deserialize(sw.BaseStream, deserialization()); 
                } 
            } 
        } 


Please find the sample from the following location: 

Regards, 
Thirupathi B. 
 



TC Travis Chambers June 28, 2018 01:03 AM UTC

Thanks for this update! This did the trick perfectly. I do have another question however.

 I have a situation in which I have multiple controls that hold different reports using the pivotgrid (different fields but same data source). In order to refresh these reports I would like to simply loop through each control (I.e. foreach(control c in this.controls)) and deserialize the pivotgrid with each control's related XML (the data range used is automatically selected and the controls updated in the loop). The problem is that when the Deserialize method is called more than once in the loop the pivotgrid freezes (I assume it never finishes some sort of task in the process). I have come up with a work around by simply removing the pivot grid and adding in a new one each time the loop runs. This is not very efficient though and I would also like to be able to deserialize the pivotgrid for each of the reports while also deserializing only the filters selected from the most recent report into each report (deserialize the main info and then deserialize the filters from a different xml file) but I cannot do that if I am removing and adding in a new pivot grid with each iteration. Is there some way to allow the deserialization multiple times in a loop? Also, is there a better way to implement a filter from one xml file into another or simply have the filter fields remain when the rest of the fields are deserialized, effectively filtering all reports that come out of the pivot grid?


TB Thirupathi Bala Krishnan Syncfusion Team June 29, 2018 12:44 PM UTC

Hi Travis, 

Please find our response as below, 

S.No 
Query 
Response 
1 
 The problem is that when the Deserialize method is called more than once in the loop the pivotgrid freezes  
We have checked your requirment–“Pivotgrid is freezed while calling the deserialize method for multiple controls.” But we are unable to reproduce the reported issue in our application. 

We have tried more possibilities to reproduce the reported issue by preparing sample with number of PivotGrid controls. We have tried to serialize/ deserialize the application as you mentioned and everything is working as expected. 

Please find our working sample from the following location: 

If the issue is still persists in your side, could you please modify the attached sample to reproduce the reported issue, so that it would be helpful to provide the prompt solution at the earliest. 

2 
Also, is there a better way to implement a filter from one xml file into another or simply have the filter fields remain when the rest of the fields are deserialized, effectively filtering all reports that come out of the pivot grid? 
As per the default behavior, you can deserialize the saved state of a specific report alone. i.e., When you are deserializing any existing file, your control will be modified based on the provided .xml file and you can’t maintain the states of any existing fields of your control. It is not a proper approach and it breaks the consistency of serialization. 

The filter fields are not maintained while deserializing  from another xml file. Only the fields are maintained if the serialized .xml file contains filter items. 



Regards, 
Thirupathi B. 
 


Loader.
Up arrow icon