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