-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infinite Scroll not working when reusing a grid #2827
Comments
I think I fixed this in my project by calling $scope.gridApi.infiniteScroll.dataLoaded(); when I fill the data grid array(in my promise.then(function (data) {...}) method), instead of calling it inside the gridApi.infiniteScroll.on.needLoadMoreData(...) method. |
I fixed the problem by adding an empty needLoadMoreDataTop (note the Top at the end) handler
I'm having an issue related to this feature: when I change the data collection, the grid scrolls and hides the first row. Is there a way to disable the infinite scroll up? |
Sounds like the original issue is resolved? |
@PaulL1, it is not really resolved, what happens here is that when redefining the data array, the scroll is set to 0 and the grid triggers the needLoadMoreDataTop event. Correct me if I'm wrong, but I believe in this case the event shouldn't be emitted. |
OK, then could you provide a plunker and some recreation instructions so that I can take a look? |
Sure, here it is (I used the tutorial as a template, sorry I didn't posted it with my comment before 😛). Try to scroll up and then click the "Refresh Data" button, the scroll should be back to 0, but it is a bit down. |
OK, I think what's happening is that the scroll % is staying the same, and the size of the data set has changed. So you had data from -100 to +100, and you were at 50% scroll. You change the data to be 0 to +100, and it's still at 50% scroll, but that's now about row 50. I think what you're looking for is some sort of reset method. You can do that with cellNav (if you happened to be using cellNav), and just call scrollTo row 0. Otherwise I think you could use an ng-if to clobber and recreate your grid. I'm thinking about doing some work on infinite scroll because I don't like it much, and I could look at this at the same time. I kinda feel like the code isn't clean in the way it behaves. |
Thanks for the heads up, I'll go with the cellNav and scrollTo method. |
I've made some changes to infinite scroll that I think will result in this working cleanly. I'll check the plunker once the merge comes through to release. |
Looks like they don't really clean it up - but it isn't helped by the plunker being based on the old tutorial. Perhaps take a look at the new structure. |
in case this helps anyone, I was able to resolve this issue in my case by doing the following:
|
Infinite scroll doesn't seem to work when reusing a grid which previously hit the end.... Makes sense that the callback would stop triggering if the listener is unregistered or something, but how to make this work?
I have a search form with some parameters in, i click search and then it queries the database and returns results which are put into this grid. I do a search, look at the data/scroll etc, then do another search. The data in the grid is wiped and the new data put in. (I.e. using same grid) - from this I notice 2 problems:
When I perform a second database search the scroll position does not reset to the top – and without using a new directive (cellNav) to scrollTo, I don’t know how.
Similar to this, infinite scrolling seems to stop working when you do a new search.
Is there a way to recreate the DOM element, or get the grid refreshed (do it's initialization and call registerGridApi again)?
The text was updated successfully, but these errors were encountered: