The LightSwitch Silverlight client has many nice features that you get for free.
One of these features is that it automatically saves Sort and Column user customizations on the datagrids. When a user sorts, resizes or reorders the columns of a datagrid, these customizations are stored in the IsolatedApplicationStorage.
For some cases, this feature isn’t that handy. If you have a query with an advanced order, you don’t want the client to remember any sort customizations. Luckily you can easily reset these settings by deleting these IsolatedApplicationStorage settings.
Example:
On initialize, delete all saved Sort and Column settings
partial void Application_Initialize()
{
IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings;
var sortAndColumnSettings = appSettings.Where(
setting => setting.Key.Contains("SortSettings") || setting.Key.Contains("ColumnSettings")).ToList();
foreach (var setting in sortAndColumnSettings)
{
appSettings.Remove(setting.Key);
}
}
If you want to do this more precise, this is the pattern of the Key names:
Column settings: Screen.DataGridControl.ColumnSettings
Sort settings: Screen.QueryName.SortSettings
Enjoy!
Michiel
