This is a migrated thread and some comments may be shown as answers.

RadGrid Custom SaveLayout - LAYOUT only (not filters)

1 Answer 142 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Keith
Top achievements
Rank 1
Keith asked on 09 Jun 2019, 03:39 AM

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?

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 11 Jun 2019, 07:26 AM
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.
Tags
GridView
Asked by
Keith
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or