Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid vertical scrolling issue

    Hi,

    We observe an issue that the vertical scroll bar is shift automatically after we restore the scroll bar position after data updates in dataArrived.

    Basically, we store the scroll bar position before data fetching/updating and then restore the scroll bar position after dataArrived. However, we notice that when "fixedRecordHeights" is set to false, there's some internal SmartClient logic to shift the scroll bar to some other positions("scrollToRow in modifyContent"), which breaks our function to restore the scroll bar position.

    This can be reproduced on SmartClient v8.3p_2015-05-05_PowerEdition and SmartClient_v91p_2015-02-17_PowerEdition on any browsers. Please try the standalone with "worldDS" dataSource in Feature Explorer.

    Steps to reproduce:

    1. Scroll down to some position;
    2. Click the "Fetch" button.

    The scroll bar doesn't remain at the same position before the fetching and get shifted. Please check the attached image for reference.

    Please note: there's a small chance that the scroll is not shifted and get restored to the correct position. But mostly, it will be shifted to some other positions.

    Thanks,
    Robin

    Code:
    isc.ListGrid.create({
        ID: "countryList",
        width:500, height:224, alternateRecordStyles:true,
        dataSource: worldDS,
        fields:[
            {name:"countryCode"},
            {name:"countryName"},
            {name:"capital"},
            {name:"continent"}
        ],    
        fixedRecordHeights:false,
        autoFetchData:true,
        dataArrived: function(startRow, endRow) {
        // Reset the scroll bar position.
            if (this.$trueFetch) {
                var table = this;
                var scrollBarPos= this.$scrollBarPos;
                if (scrollBarPos == null)
                    scrollBarPos = 0;
                isc.Timer.setTimeout(function () {
                    if (table!= null && table.body != null)
                    table.body.scrollTo(0, scrollBarPos);             
                });
                this.$scrollBarPos = null;  
                this.$trueFetch = false;
            }
        }    
    });
    
    
    isc.IButton.create({
        left:140, top:240, width:150,
        title:"Fetch",
        click: function() {
            countryList.$trueFetch = true;
            countryList.$scrollBarPos = countryList.body.getScrollTop();
            countryList.invalidateCache();
        }
    });


    Attached Files

    #2
    Thanks for the test case - we do see an oddity here. We'll take a look and let you know what we discover.

    Comment


      #3
      The problem here is that, with fixedRecordHeights:false and incremental rendering and/or loading of data, a scroll position in pixels is actually a meaningless number, because we don't know the heights of records that are not being rendered.

      So instead of using scrollTo() with a pixel position, you need to figure out what row is currently at the top of the viewport (eg getVisibleRows()) and restore that via scrollToRow().

      Comment

      Working...
      X