:: Home >>

ScrollIntoView function

Here is a little useful function which can help you to set scroll position on initial view or reload:

function scrollIntoView(index){ 

    var row = this.getTemplate("row", index); 
    var data = this.getTemplate("layout").getContent("data"); 
    var left = this.getTemplate("layout").getContent("left"); 
    var scrollbars = this.getTemplate("layout").getContent("scrollbars"); 

    try { 
        var top, padding = parseInt(data.element().currentStyle.paddingTop); 
        if (data.element().scrollTop > row.element().offsetTop - padding) { 
            top = row.element().offsetTop  - padding; 
            left.element().scrollTop = top; 
            data.element().scrollTop = top; 
            scrollbars.element().scrollTop = top; 
        } 

        if (data.element().offsetHeight + data.element().scrollTop < 
            row.element().offsetTop + row.element().offsetHeight ) { 
            top = row.element().offsetTop + row.element().offsetHeight - data.element().offsetHeight; 
            left.element().scrollTop = top; 
            data.element().scrollTop = top; 
            scrollbars.element().scrollTop = top; 
        } 
    } 
    catch(error){ 
        // ignore errors 
    } 
} 

obj.timeout(function(){ 
    scrollIntoView.call(obj, 15); 
});

Comments

2 Jul 11
Using scrollIntoView Bill (3)
6 Aug 10
[no subject] Joe (3)
14 Dec 07
Cant work when Set scrollbars.element().scrollTop...?? ray (0)
29 Aug 07
Can I specify the starting position for a table? Chunkai (21)
22 Jul 06
What does "data" refer to? Vijayakumar OA (0)
27 Jan 06
Header freezes when I scroll table AK (2)
23 Jan 06
Data Rows not scrolling... Ron (4)
9 Jan 06
[ScrollIntoView] How to show a given row as the first visible row Francesco Pezzato (0)
25 Nov 05
ScrollIntoView function Paul de Ridder (0)
10 Oct 05
Do you have a working example? Norbi (0)
13 Apr 05
starting a page with table scrolled to the bottom Greg (5)
31 Mar 05
How to syncronized two grids? Luis Méndez (1)
15 Feb 05
Display a range of data from a .CSV file Gil (4)
3 Dec 04
My misstake or bug when setting selected row? Henry (1)

Comments will appear on this page and in the main forum.

Documentation:

Recent changes:

2.6.4
2.6.3
2.6.2
2.6.1
2.6.1
2.6.0
2.5.0 - 2.5.6
2.5.6
2.5.0 - 2.5.5
2.5.5