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"/>
The August SR does fix the StackOverflow exception.
I was reading over the August Service Release Notes for Silverlight, and it looks like this might be fixed. I'll be upgrading SR's later today and testing.
Mike
Well, the way you only save certian items is using the persistance manager.
<ig:PersistenceManager.Settings><ig:PersistenceSettings SavePersistenceOptions="OnlySpecified" LoadPersistenceOptions="OnlySpecified">
<ig:PersistenceSettings.PropertySettings>
<ig:PropertyNamePersistenceInfo PropertyName="ColumnMovingSettings"/>
<ig:PropertyNamePersistenceInfo PropertyName="SortingSettings"/>
<ig:PropertyNamePersistenceInfo PropertyName="Columns[].FilterColumnSettings" Options="Contains"/>
</ig:PersistenceSettings.PropertySettings>
</ig:PersistenceSettings>
</ig:PersistenceManager.Settings>
so that will only save moving, sorting, and filtering. You can limit what you need by adding to it or removing items.
make sure in the manager you have
<ig:PersistenceSettings SavePersistenceOptions="OnlySpecified" LoadPersistenceOptions="OnlySpecified">
OnlySpecified is what you need to limit what is saved.
as far as the stack overflow issue, that was a error in the control. I know they made a patch that fix this issue. I am not sure if it is out, but i am using a pre-released version and it works fine for me. So maybe someone can tell us when a real patch is going to be released.
Hope that helps some,
Ben
Same here. Is there anything you can add that will help us out here?
Thanks,
I am also getting a Stack Overflow exception when using those settings.
It would be nice if there was an easy way (or documentation) to only save the properties a user could manipulate through the standard XamGrid UI. That's really all I want to save - if I save everything it overrides changes I make in the XAML in new versions of the software.