-
Notifications
You must be signed in to change notification settings - Fork 423
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
ScrollRowIntoView does not seen to be working with latest release #781
Comments
SlickGrid uses Virtual Scrolling to make it fast and because of that the row number keep changing when you use DataView, You need to first get the row number in the DataView by its Id before scrolling to the correct location in the virtual scroll. So you need to first find the row number in the DataView with const rowNumber = dataView.getRowById(itemId);
grid.scrollRowIntoView(rowNumber, false); The only example we have with |
Sorry for the delayed response. This did not fix the issue. This was working in the prior version, so it is a regression. |
The reason is because you're calling There 2 ways of fixing your issues,
setTimeout(() => grid.scrollRowIntoView(gotoHand()-1), 0);
grid.onRendered.subscribe(() => {
grid.scrollRowIntoView(gotoHand()-1);
}); The option 2 is probably better and I tried them both on your site and they both work. In summary, I'm very surprised that the previous code was working (allowing) to call So I'm closing this as "work as intended" and you need to choose 1 of the 2 proposed code change. |
I tried both options, the second, wait for the grid to be rendered, does not allow the grid to be scrolled past the selected row, The first, the setTimout, works and allows scrolling; however the row is at the bottom of the grid. I would like it at the top. (This is the case for both solutions). If I know how many rows are in the viewable grid I can add that #. Is there a way of determining this? Thank in advance for your help. |
As far as I can see in the PR that brought the new major release (PR #777), the only thing that changed in the This is an open source project, if you want to make this better then you can always contribute to the project. Perhaps there could be another optional argument to the function to scroll in the middle of the screen by calculating the visible viewport divided by 2... I would suggest you to contribute to the project, since I don't have time to work on this since I am already working on the next major version instead. If you think it was different in the previous version, then you should troubleshoot it yourself by adding a breakpoint into I also checked on the original SlickGrid (from the original author MLeibman) and the The example shown below is available at these 2 locations
|
@BuyInClub
So you should be using As for the reason you need to add a delay, I think it might be because the data is not fully loaded before you scroll, you have a lot of data that are loaded async and because of that the scroll height is not fully calculated so you can't scroll yet for that reason. The setTimeout is a patch, but a better fix is to add your scroll inside the DataView let alreadyScrolled = false;
dataView.onRowCountChanged.subscribe((e, args) => {
grid.updateRowCount();
grid.render();
// scroll only after loading the full dataset `> 0` but only scroll once
if (!alreadyScrolled && args.itemCount > 0) {
grid.scrollRowToTop(255);
alreadyScrolled = true;
}
}); So I think that concludes the troubleshooting and the label is correct which is "work as intended" and the reason it was working before with jQuery was maybe by luck |
Awesome, this line did it - I was working on my own method which was doing something like this - scrollRowToTop is much more exact! I will look into onRowCountChanged. If this gets triggered when the number of rows changes, then this may not work for me. The # of rows never change in the table. Many, many thanks. 3.x libraries I was using are below - <script src=https://6pac.github.io/SlickGrid/lib/firebugx.js></script> <script src=https://6pac.github.io/SlickGrid/lib/jquery-3.1.0.js></script> <script src=https://cdn.jsdelivr.net/npm/flatpickr></script> <script src=https://cdn.jsdelivr.net/npm/sortablejs/Sortable.min.js></script> <script src=https://6pac.github.io/SlickGrid/dist/slick.core.min.js></script> <script src=https://6pac.github.io/SlickGrid/dist/slick.interactions.min.js></script> <script src=https://6pac.github.io/SlickGrid/dist/slick.formatters.min.js></script> <script src=https://6pac.github.io/SlickGrid/dist/slick.editors.min.js></script> <script src=https://6pac.github.io/SlickGrid/dist/plugins/slick.rowselectionmodel.min.js></script> <script src=https://6pac.github.io/SlickGrid/dist/slick.grid.min.js></script> <script src=https://6pac.github.io/SlickGrid/dist/slick.dataview.min.js></script> <script src=https://6pac.github.io/SlickGrid/dist/controls/slick.pager.min.js></script> <script src=https://6pac.github.io/SlickGrid/dist/controls/slick.columnpicker.min.js></script> <script src=https://6pac.github.io/SlickGrid/dist/plugins/slick.resizer.min.js></script> |
the |
I beleive we have three DataView row data events now:
These should cover all the scenarios a developer would face. We added |
If you go to the URL , https://buyinclub.github.io/Table1-Details.html?hand=20 you will notice the table always starts at the beginning of the table.
The logic is in this file - https://buyinclub.github.io/handDetails.js
The data is in this file - https://buyinclub.github.io/Table1-Details.js
I debugged into the function gotoHand and it is returning the correct row # which starts at line 301 in https://buyinclub.github.io/handDetails.js
Any help really appreciated.
thanks, Dave
The text was updated successfully, but these errors were encountered: