Category / Section
How to serialize schema settings while using custom engine in WinForms GridGroupingControl?
1 min read
Serialization
In order to serialize the grid when the grid is defined with the custom engine, override the CreateFormXml and WriteXml method in CustomEngine. The XMLSerializer can be defined with the CustomEngine that you created for grid.
C#
public class CustomEngine: GridEngine
{
public override ChildTable CreateChildTable(Element parent)
{
return new GroupingChildTable (parent);
}
/// <summary>
/// Creates a valid stream for custom engine
/// </summary>
public override GridEngine CreateFromXml(XmlReader xr)
{
XmlSerializer serializer = new XmlSerializer(typeof(CustomEngine));
object obj = serializer.Deserialize(xr);
xr.Close();
return obj as CustomEngine;
}
/// <summary>
/// Saves the engine changes to an XML stream.
/// </summary>
public override void WriteXml(XmlWriter xw)
{
XmlSerializer serializer = new XmlSerializer(typeof(CustomEngine));
serializer.Serialize(xw, this);
}
}
VB
Public Class CustomEngine
Inherits GridEngine
Public Overrides Function CreateChildTable(ByVal parent As Element) As ChildTable
Return New GroupingChildTable(parent)
End Function
''' <summary>
''' Creates a valid stream for custom engine
''' </summary>
Public Overrides Function CreateFromXml(ByVal xr As XmlReader) As GridEngine
Dim serializer As New XmlSerializer(GetType(CustomEngine))
Dim obj As Object = serializer.Deserialize(xr)
xr.Close()
Return TryCast(obj, CustomEngine)
End Function
''' <summary>
''' Saves the engine changes to an XML stream.
''' </summary>
Public Overrides Sub WriteXml(ByVal xw As XmlWriter)
Dim serializer As New XmlSerializer(GetType(CustomEngine))
serializer.Serialize(xw, Me)
End Sub
End Class
Samples:
C#: Custom_Engine_Serialization
VB: Custom_Engine_Serialization
Reference link: https://help.syncfusion.com/windowsforms/gridgrouping/serialization
Didn't find an answer?
Contact Support