I have the following issue when using the CustomPropertyProvider demo (http://demos.telerik.com/silverlight/#PersistenceFramework/GridViewCustomSerialization) :
"Unable to cast object of type 'Telerik.Windows.Data.GroupDescriptor' to type 'Telerik.Windows.Controls.GridView.ColumnGroupDescriptor'."
Now I think the issue is due to the build I am using: 2012.1.314.1050
This seems to be similar to the issue posted about the WPF version of the persistance framework, although the WPF CustomPropertyProvider is different. http://www.telerik.com/community/forums/wpf/persistence-framework/typecast-error-when-persisting.aspx
7 Answers, 1 is accepted
Since Q1 2012, there were some breaking changes with the RadGridView and we have changed the implementation of the custom property provider. We have updated it in the QSF examples, so I would recommend getting and using the new implementation.
Regards,Alex Fidanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I am not sure what might be causing the issue on your side. The updated GridViewCustomPropertyProvider in the latest QSF examples should work as expected. Can you take a look at the attached sample and let me know if it works for you or modify it to reproduce the issue? That would help us better understand your scenario and what in it is causing the exception.
Thank you in advance.
Regards,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I have made the modifications that will reproduce the error and attached.
Basically I have added a loaded event to the grid and added some group descriptors in code:
private
void
gridView_Loaded(
object
sender, System.Windows.RoutedEventArgs e)
{
Deployment.Current.Dispatcher.BeginInvoke(
delegate
{
this
.gridView.GroupDescriptors.Clear();
GroupDescriptor desc1 =
new
GroupDescriptor();
desc1.Member =
"Country"
;
desc1.SortDirection = ListSortDirection.Ascending;
GroupDescriptor desc2 =
new
GroupDescriptor();
desc2.Member =
"CompanyName"
;
desc2.SortDirection = ListSortDirection.Ascending;
this
.gridView.GroupDescriptors.Add(desc1);
this
.gridView.GroupDescriptors.Add(desc2);
});
}
Then when you hit save you get the exception
This is because, you are adding GroupDescriptors instances in the GroupDescriptors collection, and the persistence framework is expecting ColumnGroupDescriptor instances. I would recommend extending the GridViewCustomPropertyProvider so that it serializes both the ColumnGroupDescriptor and GroupDescriptor classes. Using the same approach for the CGD, you can add the following:
foreach (GroupDescriptor descriotor in gridView.GroupDescriptors.OfType<
GroupDescriptor
>())
{
proxies.Add(new GroupDescriptorProxy()
{
ColumnUniqueName = descriotor.Member,
SortDirection = descriotor.SortDirection,
});
}
Alex Fidanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thankyou very much, this has fixed my issue.
I have another request though, is there any way to save the group expansion states? So if I have groups expanded in the grid, it will set that same expansion after load?
Nick
Serializing the expansion states of the rows is not directly supported. However, recently, we have created an example that persists the expansion states of the GridView rows. Following the same approach, you should be able to do the same with the group rows. I am attaching the project. Please let me know if you need further assistance.
Greetings,Alex Fidanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>