New to Telerik UI for WinFormsStart a free 30-day trial

Advanced

Updated over 6 months ago

RadVirtualGrid`s serialization API provides a wide range of options that enable the developer to customize the serialized content in a flexible manner. Based on the principles of the standard Microsoft .NET XML serialization approach, the API can be easily used for implementing different serialization scenarios.

This article demonstrates how to alter the default serialization procedure and explicitly define the properties to be serialized.

Here are several properties to have in mind:

  • RadVirtualGrid.XmlSerializationInfo: This property of RadGridView gets the serialization information used by the SaveLayout and LoadLayout methods. It contains all RadGridView data that should persist between application states.

  • RadVirtualGrid.XmlSerializationInfo.DisregardOriginalSerializationVisibility: This property determines whether the serialization engine should take the default serialization attributes or the custom serialization metadata provided by the programmer. To define a custom collection of properties, set the property to true.

  • RadVirtualGrid.XmlSerializationInfo.SerializationMetadata: This property returns a collection of PropertySerializationMetadata objects, which contains information about the type, name and serialization method of the corresponding property. You need to clear the collection in order to be sure that only the serialization instructions will be considered.

Here is a snippet clearing the default settings:

Clear Default Settings

C#
private void ClearSettings(object sender, EventArgs e)
{
    this.radVirtualGrid1.XmlSerializationInfo.DisregardOriginalSerializationVisibility = true;
    this.radVirtualGrid1.XmlSerializationInfo.SerializationMetadata.Clear();
}

Clearing the default settings would require all the serialization meta data to be loaded manually.

The code snippets below demonstrates how you can hide a particular information to be serialized: 

Define Data

C#
private void DefineData(object sender, EventArgs e)
{
    //Hide items
    this.radVirtualGrid1.XmlSerializationInfo.SerializationMetadata.Add(typeof(VirtualGridViewInfo), "CustomColumns", new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden));
    this.radVirtualGrid1.XmlSerializationInfo.SerializationMetadata.Add(typeof(VirtualGridViewInfo), "ColumnDataTypes", new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden));
    this.radVirtualGrid1.XmlSerializationInfo.SerializationMetadata.Add(typeof(VirtualGridTableViewState), "ItemSizes", new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden));
    this.radVirtualGrid1.XmlSerializationInfo.SerializationMetadata.Add(typeof(VirtualGridTableViewState), "ItemCount", new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden));
    //Sort Descriptors            
    this.radVirtualGrid1.XmlSerializationInfo.SerializationMetadata.Add(typeof(VirtualGridViewInfo), "SortDescriptors", DesignerSerializationVisibilityAttribute.Hidden);
    this.radVirtualGrid1.XmlSerializationInfo.SerializationMetadata.Add(typeof(SortDescriptor), "Direction", DesignerSerializationVisibilityAttribute.Hidden);
    //Filter Descriptors           
    this.radVirtualGrid1.XmlSerializationInfo.SerializationMetadata.Add(typeof(VirtualGridViewInfo), "FilterDescriptors", DesignerSerializationVisibilityAttribute.Hidden);
    this.radVirtualGrid1.XmlSerializationInfo.SerializationMetadata.Add(typeof(FilterDescriptor), "PropertyName", DesignerSerializationVisibilityAttribute.Hidden);
    this.radVirtualGrid1.XmlSerializationInfo.SerializationMetadata.Add(typeof(FilterDescriptor), "Operator", DesignerSerializationVisibilityAttribute.Hidden);
    this.radVirtualGrid1.XmlSerializationInfo.SerializationMetadata.Add(typeof(FilterDescriptor), "Value", DesignerSerializationVisibilityAttribute.Hidden);
    this.radVirtualGrid1.XmlSerializationInfo.SerializationMetadata.Add(typeof(FilterDescriptor), "IsFilterEditor", DesignerSerializationVisibilityAttribute.Hidden);
}

Once the layout is being loaded the LayoutLoaded event is being thrown in order to notify that the load process is being finished.

See Also

In this article
See Also
Not finding the help you need?
Contact Support