I have a XamDataGrid which I allow the user to group by columns. However, when a item changes its value in a specific column, which would force the item to be sent to a different column group, the xamDataGrid is not refreshing the grouping.
Hello durga,
I see that you have recently opened a private support case (CAS-187346-K6X0T9), of which I have recently answered.
As a quick review, this issue does not appear to have to do with the fact that the updates are coming from a separate thread, but rather, that the Field is either alternately bound or unbound and its FieldSettings' CellVisibilityWhenGrouped property is set to either Collapsed or Hidden. This is unexpected behavior, and I have logged development issue 242782 in our internal tracking systems to ensure it receives attention by our engineering staff at the head of the XamDataGrid. I have linked the above-mentioned support case to this issue so that you can track it and be notified of when a fix happens.
In the support case, I had suggested a workaround by utilizing the XamDataGrid.GetRecordFromDataItem method. Below is a transcript of that workaround:
"As a workaround to this, I would recommend that you obtain the record that has been updated by using the XamDataGrid.GetRecordFromDataItem method. In this case, you can pass in the data item that you are updating and call the RefreshSortPosition() method on the returned record from the grid. The code for this would look like the following:"
myXamDataGrid.GetRecordFromDataItem(myDataItem, true).RefreshSortPosition();
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Thanks for the reply. Please find attached sample program which will reproduce the issue where DataValueChanged event is not being fired.
Hello Durga,
The XamDataGrid's EditModeEnded event only ever fires when a particular cell actually enters edit mode through the UI of the application and then the user exits by focusing away from the cell, and so it is expected that when a value changes programmatically, the EditModeEnded event does not fire. The CellValuePresenter's Value property will only actually raise "changed" events when the cell being presented is actually in view as well, since the CellValuePresenters are virtualized and recycled by default, and if a particular cell is not in view at a particular time, its CellValuePresenter will return null.
In order to detect grouping and value changes in the XamDataGrid through an event, I would first recommend the Grouped event of the XamDataGrid. This event fires when the XamDataGrid is grouped through UI operations. It does not currently fire if the grouping has been made programmatically, as we make the assumption that an event should not be needed in this case, as you would know when the group happens programmatically and can carry out your logic there.
As for actual value changes, I would recommend using the DataValueChanged event of the XamDataGrid for this. In order to actual hook this event, you will need to set the XamDataGrid.FieldSettings.DataValueChangedNotificationsActive property to true, and being that it sounds like you want to handle value changes on any particular record in the XamDataGrid, I would also recommend that you set the XamDataGrid.FieldSettings.DataValueChangedScope to "AllAllocatedRecords". This event will then fire whenever a particular value for a cell in one of your XamDataGrid records changes.
I have attached a sample project to demonstrate the above.
EditModeEnded event is not being fired when I group by a field and the value is changed by a service (Not by user). I tried subscribing to CellValuePresenter value changed event. But, that is fired only when the column is made visible after grouping. I do not want to show that column in the record when it is grouped by.
Is there an event I can subscribe to, which is fired when a field is grouped by and the value changes ?
That did the trick.
Thanks