Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
168
rated 0 times [  169] [ 1]  / answers: 1 / hits: 15604  / 9 Years ago, thu, november 12, 2015, 12:00:00

I am using google visualization table to create an html table, and it enables The header row remains fixed as the user scrolls.



I got something working like this: http://jsfiddle.net/RjHMH/114/



The problem I am facing is that, when I click a row to expand the table, it actually redraw the table, so that the scroll bar will always be at the top of the table. Is there anyway I can track the current position of the scroll bar when I click, and set the value back when the table is redrawn?



If it is a scroll bar of the DOM, I can use:



var pos = $('body').scrollTop();
table.draw(view, options);
window.scrollTo(0, pos);


Then how to track the scroll bar inside a div?


More From » jquery

 Answers
21
document.getElementsByClassName(google-visualization-table)[0].children[0].onscroll = function(){
console.log(this.scrollTop); //check the number in console
}


The key is to get the div in js, or use jquery, then you can visit the scrollTop of that div.


[#64414] Tuesday, November 10, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
darennevina

Total Points: 422
Total Questions: 128
Total Answers: 105

Location: Comoros
Member since Tue, Mar 14, 2023
1 Year ago
;