Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
IgGrid auto scroll to top when update data source
posted

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 appear
If 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

Parents
No Data
Reply
  • 2155
    Offline posted

    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 position
    var 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.

Children