When we have a filter applied, and a selected record's data changes such that it should be filtered out, the record does not disappear until a different record is selected. If that record is the only item left visible in the grid, it's impossible to deselect the selected record, so it does not disappear. How can I make it so that a record disappears regardless of whether or not it is selected?
Here is my xaml:
<grid:NTGrid x:Name="grdOrder" Grid.Row="1" AutoFit ="False" FieldLayoutInitialized ="OnFieldLayoutInitialized" GroupByAreaLocation ="None" GroupByAreaMode ="DefaultFieldLayoutOnly" Tag ="OrderGrid" > <grid:NTGrid.FieldSettings> <igDp:FieldSettings AllowEdit ="False" CellClickAction ="SelectRecord" GroupByRecordPresenterStyle="{StaticResource OrdersGridGroupByRecordPresenter}" LabelClickAction ="SortByOneFieldOnly" LabelTextAlignment ="Center" LabelTextWrapping ="NoWrap"/> grid:NTGrid.FieldSettings> <grid:NTGrid.FieldLayoutSettings> <igDp:FieldLayoutSettings AllowClipboardOperations ="Copy" AllowDelete ="False" AllowFieldMoving ="WithinLogicalRow" AutoFitMode ="OnlyWithVisibleStarFields" AutoGenerateFields ="False" CopyFieldLabelsToClipboard ="True" HeaderPlacementInGroupBy ="OnTopOnly" HeaderPrefixAreaDisplayMode ="FieldChooserButton" MaxSelectedRecords ="1" RecordSelectorLocation ="None" ReevaluateFiltersOnDataChange ="True" SelectionTypeCell ="None" SelectionTypeRecord ="Single" /> </grid:NTGrid.FieldLayoutSettings>
Hello Jon,
This behavior is actually expected. If a cell that is to be filtered out changes its value programmatically, but that cell or the record that cell belongs to is selected, it will not be filtered out until it is deselected.
There are multiple ways that you can about programmatically controlling this - the simplest being to deselect the record or cell that is selected when your data changes. For example, you will know when the underlying data item changes, and then you can use the GetRecordFromDataItem method of the XamDataGrid to get the DataRecord that represents that item. If that DataRecord's IsSelected property is true, you can set this property to false to deselect it.
If a filter is applied, you can then get it from the corresponding FieldLayout.RecordFilters collection. The RecordFilter object has a MeetsCriteria method that takes a DataRecord so that you can determine whether or not the underlying data record meets the filter criteria or not. If it doesn't, you can mark the DataRecord.IsSelected property false to deselect it, which will subsequently filter out the record.
Please let me know if you have any other questions or concerns on this matter.
Did anyone ever solve this? I'm having the same issue with version16.2.20162.2237. The updated row doesn't get filtered out until I select another row.
Hello Stefan,
I believe what I am trying to achieve corresponds with the other posts in this thread. The difference to your sample application is that the user may not edit the cells. The change is caused by an update to the observable collection. If a record happens to be selected while the cell value changes (so that it should now be filtered out) it still stays in the grid. It is only filtered out after the selection has been removed. I would like every record (that corresponds to the filter) to be filtered out regardless of its selection state.
Is there a work around for this?
Any help would be greatly appreciated.
I am working with Version 13.2
Hello Mark,
Were you able to try my suggestion (set the XamDataGrid's UpadateMode to OnCellChangeOrLostFocus)? I created a sample project for you using this approach and everything seems to work ok on my side. If the sample doesn’t satisfies your needs, feel free to modify it, so it reproduces your behavior and send it back to us, so we could be able to investigate it further for you.
Looking forward for your reply.
By any chance has a solution to this ever been provided, as we're currently up against the same issue?
To recap - You have a filter on a XamDataGrid, and say Row X is selected. Now Row X has had a property change notification fired such that that row should now be filtered out of the the XamDataGrid.
If the row was not selected, this works just fine. If it is selected however, it incorrectly remains in view until you click somewhere else or scroll it out of view. It seems the filter disregards the currently selected row.
Has a solution ever been found for this please?
Thanks!