This is a migrated thread and some comments may be shown as answers.

GridViewCustomSerialization New Builds

7 Answers 69 Views
PersistenceFramework
This is a migrated thread and some comments may be shown as answers.
Nick Wood
Top achievements
Rank 1
Nick Wood asked on 30 Apr 2012, 03:13 AM

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

Sort by
0
Alex Fidanov
Telerik team
answered on 01 May 2012, 02:06 PM
Hi,

 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 >>

0
Nick Wood
Top achievements
Rank 1
answered on 02 May 2012, 11:37 AM
Hi Alex, I was using the latest QSF demos, it still has the same issues.
0
Tina Stancheva
Telerik team
answered on 07 May 2012, 12:54 PM
Hello Nick,

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 >>

0
Nick Wood
Top achievements
Rank 1
answered on 08 May 2012, 06:11 AM
Hi Tina

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
0
Alex Fidanov
Telerik team
answered on 10 May 2012, 04:26 PM
Hi Nick,

 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,
                    });
                }

Greetings,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Nick Wood
Top achievements
Rank 1
answered on 11 May 2012, 01:59 AM
Hi Alex

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
0
Alex Fidanov
Telerik team
answered on 14 May 2012, 07:57 AM
Hi 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 >>

Tags
PersistenceFramework
Asked by
Nick Wood
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Nick Wood
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or