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

[Solved] Need assistance - Q3 Breaking Changes

3 Answers 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kathleen
Top achievements
Rank 1
Kathleen asked on 08 Dec 2010, 04:28 PM
I really need to upgrade our solution to the latest release, but I am not yet certain how to fix this code.

I have read this posting:  http://www.telerik.com/community/forums/silverlight/gridview/sortdescriptor-and-groupdescriptor-broke-in-q3-release.aspx

But the reply there doesn't give me a good indication what I need to change given the loss of the Member property:

private static void SaveSortPreferences(CustomDataGrid gridView, GridPreference preference)
        {
            if (gridView.SortDescriptors == null) return;
  
            // Starts clean
            foreach (var entity in preference.SortLayout.SortInfos)
            {
                preference.SortLayout.SortInfos.Remove(entity);
            }
  
            foreach (var d in gridView.SortDescriptors)
            {
                var setting = preference.SortLayout.SortInfos.FirstOrDefault(q => q.PropertyName == d.Member);
                if (setting == null)
                {
                    setting = new SortInfo();
                    setting.ParentId = preference.SortLayout.Id;
                    setting.PropertyName = d.Member;
  
                    preference.SortLayout.SortInfos.Add(setting);
                }
  
                setting.SortDirection = d.SortDirection;
            }
        }

3 Answers, 1 is accepted

Sort by
0
Kathleen
Top achievements
Rank 1
answered on 08 Dec 2010, 04:43 PM

I think I figured out the solution.  assuming that Column.UniqueName is the same as the old sortdescriptors.member?

private static void SaveSortPreferences(CustomDataGrid gridView, GridPreference preference)
{
    if (gridView.SortDescriptors.OfType<ColumnSortDescriptor>() == null) return;
    // Starts clean
    foreach (var entity in preference.SortLayout.SortInfos)
    {
        preference.SortLayout.SortInfos.Remove(entity);
    }
    foreach (ColumnSortDescriptor d in gridView.SortDescriptors.OfType<ColumnSortDescriptor>())
    {
        var setting = preference.SortLayout.SortInfos.FirstOrDefault(q => q.PropertyName == d.Column.UniqueName);
        if (setting == null)
        {
            setting = new SortInfo();
            setting.ParentId = preference.SortLayout.Id;
            setting.PropertyName = d.Column.UniqueName;
            preference.SortLayout.SortInfos.Add(setting);
        }
        setting.SortDirection = d.SortDirection;
    }
}
0
Accepted
Veselin Vasilev
Telerik team
answered on 08 Dec 2010, 04:43 PM
Hi Kathleen,

Your code should look like this:

private static void SaveSortPreferences(CustomDataGrid gridView, GridPreference preference) 
        
            if (gridView.SortDescriptors == null) return
    
            // Starts clean 
            foreach (var entity in preference.SortLayout.SortInfos) 
            
                preference.SortLayout.SortInfos.Remove(entity); 
            
    
            foreach (var d in gridView.SortDescriptors.OfType<ColumnSortDescriptor>()
            
                var member = (d.Column as GridViewDataColumn).GetDataMemberName();
                var setting = preference.SortLayout.SortInfos.FirstOrDefault(q => q.PropertyName == member); 
                if (setting == null
                
                    setting = new SortInfo(); 
                    setting.ParentId = preference.SortLayout.Id; 
                    setting.PropertyName = member
    
                    preference.SortLayout.SortInfos.Add(setting); 
                
    
                setting.SortDirection = d.SortDirection; 
            
        }

Hope this helps.

Best wishes,
Veselin Vasilev
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Kathleen
Top achievements
Rank 1
answered on 08 Dec 2010, 04:44 PM
Thank  you!
Tags
GridView
Asked by
Kathleen
Top achievements
Rank 1
Answers by
Kathleen
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or