You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently using DynamicData to populate, filter and sort the datasource for my TreeDataGrid. This all works wonderfully except when I try to change a field in the Grid which triggers re-sorting of that row. When the sort happens, it seems that the TreeSelectionNode triggers OnSourceChanged with a Moved action with this value (only the index changes):
{"Action": "Move","NewItems": [<RowModel> // Same as OldItems
],
"NewStartingIndex": 0, // The sort is moving it to the top, as expected
"OldItems": [
<RowModel> // Same as NewItems
],
"OldStartingIndex": 10
}
The Moved action throws a NotSupportedException. From reading the OnSourceCollectionChanged method, it seems to me that this Move action could potentially be easily implemented by using almost the same implementation as the one for Replaced?
Willing to contribute to this if needed unless someone already has an idea of how to do this.
For reference, the best way to reproduce this is to create a DynamicData SourceCache and then sort it on a value that you then change.
Here is a reproduction of what I'm doing but in
ie:
usingSystem.Collections.ObjectModel;usingSystem.Reactive.Linq;usingAvalonia.Controls;usingDynamicData;usingDynamicData.Binding;usingReactiveUI;usingReactiveUI.Fody.Helpers;publicclassPerson(intId,stringName,boolPinToTop):ReactiveObject{publicintId{get;init;}=Id;publicstringName{get;init;}=Name;[Reactive]publicboolPinToTop{get;init;}=PinToTop;}publicclassProgram{publicstaticvoidMain(){SourceCache<Person,int>test=new(x =>x.Id);test.Connect().AutoRefresh(model =>model.PinToTop)// Re-evaluate the sort when this property is updated.Sort(SortExpressionComparer<Person>.Descending(x =>x.PinToTop).ThenByDescending(t =>t.Name),SortOptimisations.ComparesImmutableValuesOnly,25).ObserveOn(RxApp.MainThreadScheduler).Bind(outReadOnlyObservableCollection<Person>people);vardataSource=newFlatTreeDataGridSource<Person>(people);// Then use datasource from the view}}
I'm currently using DynamicData to populate, filter and sort the datasource for my TreeDataGrid. This all works wonderfully except when I try to change a field in the Grid which triggers re-sorting of that row. When the sort happens, it seems that the
TreeSelectionNode
triggersOnSourceChanged
with aMoved
action with this value (only the index changes):The
Moved
action throws aNotSupportedException
. From reading the OnSourceCollectionChanged method, it seems to me that thisMove
action could potentially be easily implemented by using almost the same implementation as the one forReplaced
?Willing to contribute to this if needed unless someone already has an idea of how to do this.
For reference, the best way to reproduce this is to create a DynamicData SourceCache and then sort it on a value that you then change.
Here is a reproduction of what I'm doing but in
ie:
Here are my package references:
Environment:
TreeDataGrid Version: 11.0.2
Avalonia Version: 11.0.6
Operating System: Windows 10
The text was updated successfully, but these errors were encountered: