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

Serialize filtered datatable in XML

Hello,

even if I know that there is a special forum for the GGC I want to ask my question in this forum because I think that it´s a general question.

I use the Filterbar feature in a GGC and need to serialize the filtered data in XML with the WriteXML method of the datatable object in the following way.

Try
Dim xw As New XmlTextWriter("c:\temp\apoInventarListe.xml", System.Text.Encoding.UTF8)
xw.Formatting = Formatting.Indented
Dim dt As DataTable = Me.grdgrpXLImport.DataSource
dt.WriteXml(xw, XmlWriteMode.WriteSchema)
xw.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

But as a result of this code I always get the complete datatable and not only the filtered rows from the GGC.

Can anyone help me to serialize only the filtered rows of a datatable.

Thank you very much
Karsten

4 Replies

AD Administrator Syncfusion Team July 21, 2006 12:39 PM UTC

Hi Karsten,

Please refer the forum thread for Serialize grouping table descriptor.
http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=41724

You can Save the GridEngine changes to xml using the Engine.WriteXml method and intialize GridEngine from Xml using CreateFromXml method. Here is a code snippet.

// intialize GridEngine from Xml
System.IO.FileStream file = new FileStream("XML11.xml",FileMode.Open);
System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(file);
GridEngine engine = GridEngine.CreateFromXml(xr);
this.gridGroupingControl1.Engine.InitializeFrom(engine);
xr.Close();

//GridEngine changes to xml
System.IO.FileStream file = new FileStream("XML11.xml",FileMode.OpenOrCreate);
System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(file,System.Text.Encoding.UTF8 );
this.gridGroupingControl1.Engine.WriteXml( writer);
writer.Close();

Best regards,
Haneef


KB Karsten Brocksieper July 21, 2006 06:09 PM UTC

Hi Haneef,

thank you for your answer but unfortunately your suggestion is not the solution in my case.

With your suggested code and the link I can serialize the schema of the grid but not the data itself.

For example: I have a GGC with about 50 items in the datasource of the grid. Now I filter with the filterbar method and as a result there are at least only 10 items in the grid.

My problem is now that -with my code- I ALWAYS get 50 items in my XML file regardless of the filter settings.

What I want to do is just getting the filtered resultset in my serialized XML file and not all of the data from my underlying datatable.

It would be really helpful for me if you can help me.

Thank you in advance
Regards, Karsten


KB Karsten Brocksieper July 22, 2006 10:58 AM UTC

Hi,

in the meantime I have found that the visible (=filtered) records are in the FilteredRecords collection (Me.GridGrouping.Table.FilteredRecords). But actually I´m having the problem that I can´t get this collection in a DataTable object.

Can anyone help me with this?

Regards, Karsten


AD Administrator Syncfusion Team July 24, 2006 10:48 AM UTC

Hi Karsten,

Please refer the forum thread for more details.
http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=32614

Let me know if this helps.
Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon