Basic Information:Here is some information on setting some basic persistence settings on the xamGrid. If you have additional info that would be useful please add to this discussion.
References (Developer Guide-> Infragistics Control Persistence Framework):http://help.infragistics.com/Doc/Silverlight/2011.2/CLR4.0/Out of the box the persistence framework is extremely useful and saved us from countless hours of work and design. The settings are serialized to xml and easily compatible with streams. You can save and load settings from single or multiple controls into a settings group. You can easily reset settings to a default control state, or some other control state. After testing this it also works now with dynamic objects and dynamic data sources (meaning I can clear my settings and load new data or a new data source into a grid and save or load new persistence settings for the grid). There are also some good examples in the online documentation on how to get started.
Determining Which Properties to Save
It will automatically save/load all properties of the control or only the ones you specify. This really helps when you need to be concious of space and only need a handful of settings loaded or saved.
To give you an idea on the size comparison, here is the result using a grid with 5 columns:All Grid Properties: 933 KBOnly Specified: 11kb (1 property)XAML for specifying some settings and properties is listed below:
<ig:XamGrid><ig:PersistenceManager.Settings><ig:PersistenceSettings SavePersistenceOptions="OnlySpecified" LoadPersistenceOptions="AllButIgnored">
<ig:PropertyNamePersistenceInfo PropertyName="ColumnResizingSettings"/>
Its really that simple to setup. To save or load its even easier:Save persistence settings for a datagrid:
using System.IO;using Infragistics.Persistence;MemoryStream ms = new MemoryStream();ms = PersistenceManager.Save(grid);
Now you have a stream and can save to whatever store you want. Want a string you can look at, store, or print to a file quick?
var sr = new StreamReader(ms); var myStr = sr.ReadToEnd();
Another nice thing about specifying properties is that you can do it in XAML or Code, and you can override settings from XAML in Code.Code for settings:
PersistenceSettings settings = new PersistenceSettings(); settings.SavePersistenceOptions = PersistenceOption.OnlySpecified; PropertyNamePersistenceInfo prop = new PropertyNamePersistenceInfo(); prop.PropertyName = "ColumnMovingSettings"; settings.PropertySettings.Add(prop); // Save with specified settings
XamGrid grid = devGrid as XamGrid; ms = new MemoryStream(); ms = PersistenceManager.Save(devGrid, settings);
Load Persistence From Stream:
MemoryStream ms = stream; PersistenceManager.Load(grid, ms);
Load Persistence From Stream with Specific settings:
PersistenceSettings settings = new PersistenceSettings(); settings.LoadPersistenceOptions = PersistenceOption.OnlySpecified; // Add properties here// Load stream with settings specifiedPersistenceManager.Load(grid, ms, settings);
What properties?
With all the properties available in the grid you might think it would take a while to figure out which ones you want to use if your going to specify them. Fortunately it was easier than I thought to store the properties I was interested in. I managed to specify column size, column order, sorting, grouping, columns hidden/shown, and filter settings, all with the lines below.
I ended up using the following properties:
<ig:PersistenceSettings SavePersistenceOptions="OnlySpecified" LoadPersistenceOptions="OnlySpecified"> <ig:PersistenceSettings.PropertySettings>
<ig:PropertyNamePersistenceInfo PropertyName="ColumnResizingSettings"/> <ig:PropertyNamePersistenceInfo PropertyName="ColumnMovingSettings"/> <ig:PropertyNamePersistenceInfo PropertyName="SortingSettings"/> <ig:PropertyNamePersistenceInfo PropertyName="ColumnChooserSettings"/> <ig:PropertyNamePersistenceInfo PropertyName="GroupBySettings" Options="Contains"/> <ig:PropertyNamePersistenceInfo PropertyName="Columns[].FilterColumnSettings" Options="Contains"/>
Hello donschaberg,
Thank you for posting into our community. I am really glad that you manage to apply the Infragistics Persistence Framework in your application and provide us with this valuable feedback.
This shared information is really useful and I suppose that the other user will benefit from this thread and will find it very helpful.
Thank you.
Rather than calling Load and Save on the persistence manager is there some way I can bind settings to a property on my view model? i.e.
<ig:XamGrid GroupBySettings="{Binding Path=myGroupSettingsProperty}" ....
Thank you, Don. It was very helpful and saved me a great deal of effort.
Now, here's a question. I tried to persist a grid with 15 columns using the example above and the resulting memory stream was ~2MB. Having looked at the output it appears that persistence manager is being extremely verbose (which is the price of being generic). Is there a way to decrease the size of the output? If a user would persist, say, 20 different grids and we have over a 100 users, we're looking at 4GB just to save the settings.
Thank you,
Eugene
Hello Eugene,
I can see your concerns, still I can’t think of a way to reduce the memory stream using the current functionality apart from saving OnlySpecified settings, so I submitted the reducing of the size of the output as new product idea about our persistence framework. Your reference number for this product idea is PI12050091.
Thank you for your feedback.