I worked through some issues in MXRoyale datagrids earlier this year. There is an example in the mxroyale examples for testing the mx datagrids. And there is a deployment of that example build here: http://interactionscript.com/royale/mx-grids/emulation/js-release/index.html You can see if you click on the 'name' or 'sales' headers in these examples, that selection and scroll position is retained after sort. I'm only referring to this because it might provide some sort of reference example for testing behaviour. (Those grids also support multiple selection, which is a requirement for the emulation of Flex classes)
On Tue, Sep 22, 2020 at 9:52 AM Hugo Ferreira <[email protected]> wrote: > Hi, > > I understand that setting the dataProvider to null just to force a redraw > is not a good design. > I think that no one will argue against it. > > For me, losing the grid position when changing the sort it's not an issue. > What means keeping the grid position when the data is changed by a sorting > !? > But I understand that there are different visions and approaches. > > My only concern it's performance. > I have a few limit grids (I haven't got there yet with my Flex port for > Royle to do a test, but I hope to get there as soon as possible) with many, > many rows (when I say many, I mean thousands) and sorting it's very > important but also the performance while sorting. Users are used to wait to > load to many records but after the data is loaded from the server, sorting > is something that happens on the client side super faster. > > So, at the end, I would say that if performance is not affected or if > theoretical is faster, great. > > Carlos Rovira <[email protected]> escreveu no dia segunda, > 21/09/2020 > à(s) 16:40: > > > 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 > > >
