This problem has been solved already with beads. Check out DataProviderChangeNotifier EasyDataProviderChangeNotifier.
> On Sep 21, 2020, at 6:40 PM, Carlos Rovira <[email protected]> wrote: > > Hi, > > I solved the problem with sorting in DataGrid (or List). > > The problem was: a sorted dataProvider is the same object,so making > "dataProvider = sortedDP" was stopped at the start of the method since as > usual we check if dataprovider is the same and in that case we return. > > The workaround was to do > > dataProvider = null; > dataProvider = oldDP; > > This had 2 problems: > 1.- if selection was in place, the selection was lost > 2.- if some scrolling was in place, the scrolling was lost. > > So my solution, was create a new "sortChanged" event > > 1.- in DataGridSort we dispatch the "sortChanged" instead of > "dataProviderChanged" (in fact that's what really happened, right?). > 2.- DataGridView now listen for "sortChanged" too (additionally to > "dataProviderChanged"), and we have a new handler that just propagate to > make each list to call "list.model.sortChangedHandler(dp);" > 3.- the shared model, ArraySelectionModel, decouple dataProvider setter to > extract the main functionality to "setDataProvider" and add > "sortChangeHandler" that avoid to check if dataProvider is the same as > before, so this time the refresh happen. > > The solution made the selection and the scrolling be persisted (if any), so > for now this solved the problems and seems (at least) to be a step forward. > > So my question: Do you think this solution is ok? > If so, maybe the event name should change to something that describes > things "wider", since this could be a "sort" a "filtering",.... > > -- > Carlos Rovira > http://about.me/carlosrovira
