Go Back

Saving and Loading Summary Row Information in a RadGrid

One feature I really like in Telerik’s WinForms RadGrid control is the ability to save and load layout information using the Serialization API.  It’s nice to be able to to persist appearance and other settings in XML format, so that they can be restored later and provide a more consistent feel for the user.

Telerik’s Knowledge Base has a great article here on how to use the API to persist selected property values. This is quite useful if, instead of using the default values which store many many grid settings, you only want to store a few settings.  There’s even an example in this article, which can help get you started learning how to use the API to locate the desired properties.

This was the case with my application, where I needed to store the settings for Summary Rows in a RadGrid.  I found it a little tricky to get the right set of metadata serialization info for the summary rows, but it is possible!  By examining the XML file generated using default settings (which includes summary rows) and checking out the internal structure of the RadGrid’s summary rows, I finally found the right combination.  So, to anyone else wanting to persist non-typical information, hopefully this will save you a little time.  Here’s what worked for me:

this.radGridView1.XmlSerializationInfo.SerializationMetadata.Add(
   typeof(GridViewTemplate),
   "SummaryRowsBottom",
   DesignerSerializationVisibilityAttribute.Content
   );

this.radGridView1.XmlSerializationInfo.SerializationMetadata.Add(
    typeof(GridViewSummaryRowItem),
    "GridViewSummaryItem",
    DesignerSerializationVisibilityAttribute.Content
    );

this.radGridView1.XmlSerializationInfo.SerializationMetadata.Add(
    typeof(GridViewSummaryItem),
    "Aggregate",
    DesignerSerializationVisibilityAttribute.Visible
    );

this.radGridView1.XmlSerializationInfo.SerializationMetadata.Add(
    typeof(GridViewSummaryItem),
    "FieldName",
    DesignerSerializationVisibilityAttribute.Visible
    );

this.radGridView1.XmlSerializationInfo.SerializationMetadata.Add(
    typeof(GridViewSummaryItem),
    "FormatString",
    DesignerSerializationVisibilityAttribute.Visible
    );
You’ll find that this will also persist any special formatting for the summary row title, and could easily be adjusted to use the top summary rows instead of bottom.

As always, you can find more help with Telerik’s RadGridView for WinForms on Telerik’s support site, or check out Falafel’s own training classes and consulting services

  • Facebook
  • Twitter
  • DZone It!
  • Digg It!
  • StumbleUpon
  • Technorati
  • Del.icio.us
  • NewsVine
  • Reddit
  • Blinklist
  • Add diigo bookmark
Post a comment!
  1. Formatting options