RadGrid row does not update after CommitEdit

1 Answer 28 Views
GridView
Paul
Top achievements
Rank 1
Iron
Paul asked on 10 Aug 2021, 02:01 PM

I'm using the 3 lines below to try to update the CurrentItem on the grid.
The code runs but the grid does not update (shows same text on all columns in current row as before)

StaffGridView.Items.EditItem(this.StaffGridView.CurrentItem);
this.StaffGridView.CurrentItem = updatedObject;
StaffGridView.Items.CommitEdit();

 

in the xaml

ItemsSource="{Binding StaffList, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
CurrentItem="{Binding CurrentStaff, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsSynchronizedWithCurrentItem="True"

 

Is something else needed in the xaml or the code to tell the Grid to update with the change to CurrentItem?

 

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 13 Aug 2021, 01:34 PM

Hello Paul,

I have created a sample project that uses the provided code snippets, but it works correctly on my end.

The model that I used in the project, inherits the ViewModelBase abstract class, which is inside the Telerik.Windows.Controls namespace. The abstract class implements the INotifyPropertyChanged interface which is required for the changes to the property to be reflected by RadGridView's UI.

So, could you provide feedback, whether your model has implemented the mentioned interface? If they do not, could you try adding it to see if it will solve your issue? And if the problem still persists, could you modify the provided project, so that it matches your case scenario?

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Paul
Top achievements
Rank 1
Iron
commented on 13 Aug 2021, 02:39 PM

My project is not using StaffGridView_BeginningEdit so maybe this is why does not work.
If CommitEdit needs INofifyPropertyChanged to work then I don't see what it is actually for, doesn't the grid automatically update when properties change when INofifyPropertyChanged is present?

Anyway, I update the BindingList bound to ItemsSource and it is reflected on the screen.
(because CommitEdit does not do what I thought it would)

Stenly
Telerik team
commented on 16 Aug 2021, 03:31 PM

I am glad that you have found a solution to your issue.

The CommitEdit method updates the filtering, grouping, and sorting of the control. The INotifyPropertyChanged interface implementation is still needed. Also, the following documentation explains about updating editing items, outside of the data grid:

WPF DataGrid | Reapply data operations when property changes | Telerik UI for WPF

Tags
GridView
Asked by
Paul
Top achievements
Rank 1
Iron
Answers by
Stenly
Telerik team
Share this question
or