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

SortDescriptors Not Updating in Usercontrol

1 Answer 114 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kieron
Top achievements
Rank 1
Kieron asked on 08 Nov 2017, 11:01 PM

I've got the following radgridview control with a default sort descriptor on it:

<telerik:RadGridView x:Name="rgvMain" VerticalAlignment="Top" AutoGenerateColumns="False" CanUserResizeRows="False" CanUserInsertRows="False" CanUserSortGroups="False" ShowGroupPanel="False"
                        RowIndicatorVisibility="Collapsed" ItemsSource="{Binding CurrentActivities}" Visibility="{Binding CurrentActivitiesVisibility}">
       <telerik:RadGridView.Columns>
         <telerik:GridViewDataColumn DataMemberBinding="{Binding DateAndTimeLogged}" Header="Date Logged" UniqueName="LogDate" Width="Auto" IsReadOnly="True" />
         <telerik:GridViewDataColumn DataMemberBinding="{Binding TypeDescription}" Header="Type" UniqueName="TypeDescription" Width="Auto" IsReadOnly="True"/>
         <telerik:GridViewDataColumn DataMemberBinding="{Binding ActivityStudent.FullName}" Header="Student" UniqueName="StudentName" Width="Auto" IsReadOnly="True" />
         <telerik:GridViewDataColumn DataMemberBinding="{Binding ActivityStudent.Family.Name}" Header="Family" UniqueName="FamilyName" Width="Auto" IsReadOnly="True"/>
         <telerik:GridViewDataColumn DataMemberBinding="{Binding ActivityText}" Header="Report" UniqueName="Report" Width="Auto" IsReadOnly="True"/>
       </telerik:RadGridView.Columns>
       <telerik:RadGridView.SortDescriptors>
         <telerik:ColumnSortDescriptor Column="{Binding Columns[LogDate], ElementName=rgvMain}" SortDirection="Descending"/>
       </telerik:RadGridView.SortDescriptors>
     </telerik:RadGridView>

 

The ItemsSource is bound to:

public ObservableCollection<Activity> CurrentActivities
{
  get { return new ObservableCollection<Activity>(Utils.AllActivities.Where(x => x.LoggedUser == Utils.glbCurrentlyLoggedInUser)); }
}

 

Whenever the usercontrol is first loaded - the sortdescriptors work, but then any future loads of the usercontrol, the sortdescriptors/filters get lost - I've tried adding a Rebind to the GV on the usercontrol loaded but this doesn't make a difference.

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 13 Nov 2017, 12:18 PM
Hello Kieron,

I have tested the scenario you described and everything works as expected. I am sending you the sample project I used for reproducing the case. Please take a look at it and let me know in case of any misunderstandings.

Regards,
Martin Vatev
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Kieron
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or