We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

serializing a GridModel used as part of a datastructure

In the attached example I use a GridModel as a scratchpad structure. Unless I have copied values
into this GridModel, I am unable to save and load the data structure successfully. Is there a way to
do so? In the real app, the GridModel may be empty because there are a lot of preliminary steps
which the user must complete before reaching the step where the scratchpad is used. This could
take days or weeks. Hence, saving at intermediate stages becomes a necessity.
 
v/r
Jan
 


Example_8bc3178a.rar

3 Replies

KB Kalaiarasan B Syncfusion Team July 30, 2012 07:10 AM UTC

Hi Jan,

 Thank you for your interest in Syncfusion products.

 You can serialize the GridModel directly to binary format using the SaveBinary() and so you can use the following way to achieve the desired behavior instead of serializing using BinaryFormatter and Stream.

 // Serialize

if (dr == System.Windows.Forms.DialogResult.OK)

            {

                dataStructure.Textbox1Text = textBox1.Text;

                dataStructure.Textbox2Text = textBox2.Text;

                this.gridControl1.Model.SaveBinary(saveFileDlg.FileName);

            }

 

//Deserialize

if (dr == System.Windows.Forms.DialogResult.OK)

            {

                this.gridControl1.Model = GridModel.LoadBinary(openFileDlg.FileName);

                this.gridControl1.Refresh();

                textBox1.Text = dataStructure.Textbox1Text;

                textBox2.Text = dataStructure.Textbox2Text;

            }

 Sample for your reference

 http://www.syncfusion.com/downloads/Support/DirectTrac/96689/Example-349884176.zip

 Please let us know if you have any concerns

 Regards,

Kalai



AD Administrator Syncfusion Team July 30, 2012 10:09 PM UTC

Your approach saves the grid model but does not save the data structure. I wish to save a data structure, one element of which is a grid model, as a single file. Using your approach would require saving the data structure as 2 files (1 file for the 'non-grid' data elements and another for the grid model).


KB Kalaiarasan B Syncfusion Team August 2, 2012 12:35 PM UTC

Hi Jan,

Hi Jan,

It is not possible to save the GridModel like in your sample, only LoadBinary, LoadSoap can serialize the GridModel without any null refernce exceptions. 

So it would be better if you serialize the Grid and the datastructure in the previous approach.

Regards,
Kalai

Loader.
Live Chat Icon For mobile
Up arrow icon