Hi all,
I currently use Infragistics Version=11.1.2011.2116.
How do I set the serialization flag in code behind for the following?
Type 'Infragistics.Web.UI.GridControls.GroupedColumns' in Assembly 'Infragistics4.Web.v11.1, Version=11.1.20111.2116, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb' is not marked as serializable.
Unfortunately documentation in this regard is greatly lacking.
Regards,
Tom
Hi Alex,
Thanks for the reply. I have looked at the Persistence framework, but it is very cumbersome.
I only need to persist very specific pieces of control data and not the complete control.
If there is a way to achieve this with the Persistence Framework please enlighten me, otherwise, could you please advise me on a way to achieve my original goal.
Hello Tom,
Yes, you can persist a particular peaces of the grid. Let say you want to persist the WebHierarchicalDataGrid's Behaviors property. All you need to do is:
//Persisting:
PersistenceManager manager = PersistenceManager.GetInstance();
ControlData data = manager.SaveControl(this.WebHierarchicalDataGrid1.Behaviors, "WebHierarchicalDataGrid1Behaviours");
string xml = data.ToXml(); //save this xml somewhere
//Restoring:
ControlData data2 = ControlData.FromXml(xml);
manager.LoadControl(this.WebHierarchicalDataGrid1.Behaviors, data2);
Thanks
Ivan
Hello Ivan & co.,
Thank you for the information. This was very helpful.
I am however still not able to fully persist the grid column layout data.
Is there an example you can point me too, to achieve this.
I am specifically interested in the column widths as I would like to persist this information between user sessions.
Did you try to resize the column sizes prior to persist them? Also, please enable the resizing behavior like this:
<
Behaviors>
</
Resize some columns when page is loaded and try again to persist the columns collection.
Hello Ivan,
I have tried your sample code, but the column width is always empty. Whether I specify the columns from the grid or the grid.grid view - as below.
Other property data is however persisted - so I am not sure why the widths are not persisted.
Private Sub PersistenceSaved()
Dim manager As Persistence.PersistenceManager = Persistence.PersistenceManager.GetInstance()
Dim behaviorData As Persistence.ControlData = manager.SaveControl(Me.whdgDefault1.Behaviors, "gridBehaviours")
_gridSettings.PersistedBehaviors = behaviorData.ToXml()
Dim columnData As Persistence.ControlData = manager.SaveControl(Me.whdgDefault1.GridView.Columns, "gridColumns")
_gridSettings.PersistedColumns = columnData.ToXml()
End Sub
The columns are initialized before the Persistence sub is called - during the grid.initializeband event.
Any other ideas?
--Tom
if you want to persist the Column on the Root level you can call:
PersistenceManager
manager = PersistenceManager.GetInstance();
ControlData
data = manager.SaveControl(WebHierarchicalDataGrid1.Columns,
"WebHierarchicalDataGrid1Columns");
If you want to persist the Columns of the first sub-band you can call:
data = manager.SaveControl(WebHierarchicalDataGrid1.Bands[0].Columns, "WebHierarchicalDataGrid1Columns");
Have in mind, that the columns should be defined either in code behind or in the markup of the page. If columns are auto generated this approach would not work.