GridViewCustomSerialization New Builds

8 posts, 0 answers
  1. Nick Wood
    Nick Wood avatar
    126 posts
    Member since:
    Feb 2010

    Posted 29 Apr 2012 Link to this post


    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
  2. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 01 May 2012 Link to this post

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

  3. DevCraft banner
  4. Nick Wood
    Nick Wood avatar
    126 posts
    Member since:
    Feb 2010

    Posted 02 May 2012 Link to this post

    Hi Alex, I was using the latest QSF demos, it still has the same issues.
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 07 May 2012 Link to this post

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

  6. Nick Wood
    Nick Wood avatar
    126 posts
    Member since:
    Feb 2010

    Posted 08 May 2012 Link to this post

    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
  7. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 10 May 2012 Link to this post

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

  8. Nick Wood
    Nick Wood avatar
    126 posts
    Member since:
    Feb 2010

    Posted 10 May 2012 Link to this post

    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
  9. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 14 May 2012 Link to this post

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

Back to Top
DevCraft banner