Version ignite-ui-full: 18.2.99
My project have problem with IgGrid. I need update data source object manual without API and used property "rowVirtualization=true".When data source large current height grid, scrollbar appearIf I scroll to bottom and update data source by $("#grid").igGrid(dataSourceObject", data).igGrid("dataBind"), the grid auto scroll to top
I want to keep position of scrollbar. Please help me
Hello Quoc,
Thank you for posting in Infragistics Forum.
You should be able to restore the scroll position by saving the current scroll position and resetting it using igGrid’s virtualScrollTo() method like this:
-----------------//Save the current scroll positionvar verticalContainer = $("#grid_scrollContainer");var topPos = verticalContainer.scrollTop();
//Call dataBind() $("#grid").igGrid("dataSourceObject", data).igGrid("dataBind"); setTimeout(function(){ //Reset the scroll position $("#grid").igGrid("virtualScrollTo", topPos + "px"); }, 0);-----------------
https://www.igniteui.com/help/api/2018.2/ui.iggrid#methods:virtualScrollTo
Please let me know if I may be of further assistance.
Thanks for you answer. The solution have trouble in IE browser. The user see grid scroll to top and after that scroll to bottom. IE is main browser of us. Can you help me fix that in IE?
Another way to keep the scroll position is to use a private property called _persistVirtualScrollTop. You will see the scroll position is persisted after dataBind() by adding the following code right after the grid initialization.
$("#grid").data("igGrid")._persistVirtualScrollTop = true;
Please remember that this property only works with a virtualized grid, and we cannot guarantee it to work in the future versions since it uses a private code.
Thank you,Mihoko Kamiishi
Thanks Mihoko Kamiishi,
I checked in Chrome. The grid keep position scroll when I add $("#grid").data("igGrid")._persistVirtualScrollTop = true.
But in IE 11. The grid working unstable. Sometime scroll to top, sometime scroll to near the top, sometime keep position :((
IE 11 is main browser we need support for customer. Can you help me provide other soulution for IE11?
I haven't been able to reproduce your problem with IE11 in my environment.I have attached a sample of igGrid that I used to test this, so can you please run this on your PC and see if the problem is reproducible?The button labeled "dataBind()" under the grid calls dataBind().
igGrid_scroll.zip
Thank you so much,
But in your example I edited function of button.
When I press button the grid scroll to near bottom. It is not last position scroll bar before press button.
And in my project, I use grid with multi row layout. The grid working unstable in IE when I scroll to bottom.
Please help me
Thank you
igGrid_scroll_update.zip
It seems that I'm not seeing your problem.I have recorded my testing and attached the video file.Is this not what you are seeing?If not, may I have the version of you IE11?
igGrid_scroll_update_video.zip
Thanks Mihoko Kamiishi
The solution used feature "updating" is right
If you wish to append a new row and scroll to the bottom, you may want to consider using igGridUpdating's addRow() method.
https://igniteui.com/help/api/2019.1/ui.iggridupdating#methods:addRow
I have feature scroll to bottom and focus item when append new item to grid.
Before add line code $("#grid").data("igGrid")._persistVirtualScrollTop = true;I handle by solution:// scroll to to top//scroll to index of new item
It working normal in Chrome. But it appear effect scroll to top before scroll to bottom in IE
I think if I keep current position scrollbar, I can remove effect unexpected in IE
Keeping the scroll position with grid's continuous virtualization enabled may be difficult to achieve with custom code.
May I ask what your exact use case is so that we can look for other solutions?Why are you trying to update the data source object manually without API and keep the scroll position at the same time?
I seem to need permission to download that video file.However, I reproduced the issue that the scroll position does not get restored properly when I scroll to the very bottom and call dataBind().Let me look into this problem.