RadGrid Custom SaveLayout - LAYOUT only (not filters)

2 posts, 0 answers
  1. Keith
    Keith avatar
    23 posts
    Member since:
    Nov 2011

    Posted 08 Jun 2019 Link to this post

    I've been playing around with SaveLayout and gotten it to work with the standard SaveLayout.

    But I'm looking for a way to save ONLY the layout information (column width, column order,visible columns, etc).

    I can't seem to find a way to do it.

     

    This is what I've tried so far:

    RadGridView1.XmlSerializationInfo.SerializationMetadata.Clear()
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(RadGridView), "MasterTemplate", ComponentModel.DesignerSerializationVisibilityAttribute.Content)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(GridViewTemplate), "FilterDescriptors", ComponentModel.DesignerSerializationVisibilityAttribute.Content)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(CompositeFilterDescriptor), "FilterDescriptors", ComponentModel.DesignerSerializationVisibilityAttribute.Content)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(CompositeFilterDescriptor), "LogicalOperator", ComponentModel.DesignerSerializationVisibilityAttribute.Visible)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(FilterDescriptor), "PropertyName", ComponentModel.DesignerSerializationVisibilityAttribute.Visible)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(FilterDescriptor), "Operator", ComponentModel.DesignerSerializationVisibilityAttribute.Visible)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(FilterDescriptor), "Value", ComponentModel.DesignerSerializationVisibilityAttribute.Visible)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(FilterDescriptor), "IsFilterEditor", ComponentModel.DesignerSerializationVisibilityAttribute.Visible)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(GridViewTemplate), "Columns", ComponentModel.DesignerSerializationVisibilityAttribute.Content)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(GridViewDataColumn), "Name", ComponentModel.DesignerSerializationVisibilityAttribute.Visible)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(GridViewDataColumn), "Width", ComponentModel.DesignerSerializationVisibilityAttribute.Visible)
     
     
    RadGridView1.SaveLayout(mStream)

     

    It gives me a blank result.

    THIS works for filtering but not any of the column info (width, order, visible):

    RadGridView1.XmlSerializationInfo.DisregardOriginalSerializationVisibility = True
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Clear()
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(RadGridView), "MasterTemplate", ComponentModel.DesignerSerializationVisibilityAttribute.Content)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(GridViewTemplate), "FilterDescriptors", ComponentModel.DesignerSerializationVisibilityAttribute.Content)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(CompositeFilterDescriptor), "FilterDescriptors", ComponentModel.DesignerSerializationVisibilityAttribute.Content)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(CompositeFilterDescriptor), "LogicalOperator", ComponentModel.DesignerSerializationVisibilityAttribute.Visible)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(FilterDescriptor), "PropertyName", ComponentModel.DesignerSerializationVisibilityAttribute.Visible)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(FilterDescriptor), "Operator", ComponentModel.DesignerSerializationVisibilityAttribute.Visible)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(FilterDescriptor), "Value", ComponentModel.DesignerSerializationVisibilityAttribute.Visible)
    RadGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(FilterDescriptor), "IsFilterEditor", ComponentModel.DesignerSerializationVisibilityAttribute.Visible)
     
     
     
    RadGridView1.SaveLayout(mStream)

     

    What am I missing?

  2. Dimitar
    Admin
    Dimitar avatar
    2907 posts

    Posted 11 Jun 2019 Link to this post

    Hi Keith,

    If you are binding the grid you need to serialize the FieldName property. The HeaderText property should be serialized as well:
    radGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(GridViewDataColumn), "FieldName", DesignerSerializationVisibilityAttribute.Visible)
    radGridView1.XmlSerializationInfo.SerializationMetadata.Add(GetType(GridViewDataColumn), "HeaderText", DesignerSerializationVisibilityAttribute.Visible)
     
    Please let me know if there is something else I can help you with. 
     
    Regards,
    Dimitar
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top