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

Sorting PropertyChanged event, doens't fire

1 Answer 76 Views
DataGrid
This is a migrated thread and some comments may be shown as answers.
João
Top achievements
Rank 1
João asked on 12 Oct 2017, 01:54 PM

Hello,

I'm having some trouble to get the event (PropertyChanged) fired in Telerik.Data.Core.PropertySortDescriptor().

I'm using the sample from https://github.com/telerik/UI-For-UWP/tree/master/SDKExamples.UWP

 

ColumReordering.xaml

change grid ...

 <grid:RadDataGrid x:Name="grid" Loaded="Grid_Loaded" UserGroupMode="Disabled" UserFilterMode="Disabled" UserSortMode="Single" Grid.Row="2" AutoGenerateColumns="False"/>

 

ColumReordering.xaml.cs

Remove from Constructor (DataContext)

  public ColumnReordering()
        {
            this.InitializeComponent();

            this.combo.ItemsSource = Enum.GetValues(typeof(DataGridUserColumnReorderMode));
            this.combo.SelectedItem = DataGridUserColumnReorderMode.Interactive;
        }


 private void Grid_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            var lstToBind = new List<Student>(Enumerable.Range(9, 10).Select(i => new Student { Name = "Name" + i.ToString(), Age = 9 + i }));
            var lstColumns = new List<string>() { "Name", "Age" };
            this.grid.SortDescriptors.Clear();
            foreach (var obj in lstColumns)
            {
                var col = new Telerik.UI.Xaml.Controls.Grid.DataGridTextColumn();
                col.CanUserSort = true;

                var st = new Telerik.Data.Core.PropertySortDescriptor();
                st.PropertyName = obj;
                st.SortOrder = Telerik.Data.Core.SortOrder.Descending;
                st.PropertyChanged += St_PropertyChanged;
                this.grid.SortDescriptors.Add(st);

                col.PropertyName = obj;
                col.Name = obj;
                grid.Columns.Add(col);
            }


            this.grid.ItemsSource = lstToBind;

        }

        private void St_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {

        }

 

-----------------------------------------------------------------------------------------------------------

 

St_PropertyChanged has never fired...

 

Best Regards

João Guedes

1 Answer, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 17 Oct 2017, 08:48 AM
Hello João,

From the provided code snippet we cannot see where exactly the PropertyName of the SortDescriptor changes. In order to make the event raises as expected you need to change the PropertyName property of the descriptor. For example if you handle the event before the property is set you will notice how the event is raised:
...
st.PropertyChanged += St_PropertyChanged;
st.PropertyName = obj;
...

Hope the provided information will be helpful for you.

Regards,
Nasko
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DataGrid
Asked by
João
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Share this question
or