This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Identifying position of the highlighted row

 
Varun Khanna
Ranch Hand
Posts: 1400
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table (scrollable) inside a div. At any time, only 5 rows are visible and to view rest of the rows the user have to scroll down.
Suppose user scrolls down to 16th rows and selects it, I change the "class" of the TR element that row as "highlight", in order to highlight it. Now my problem is that I should keep that highlight row at the top of currently visible enteries.
i.e. in current scenario, since I selected the 16th row, div should show 16th element and the next four (i.e. 17th,18th,19th,20th) [since I show only 5 rows at a time]

I have the index of 16th row and I use this index to scroll div upto that element using this code on body onload :
divElement.scrollTop = (index * 20);
where index is 16 (in this case) and 20 is approx height of each TR.
But this doesn't works fine. Ideally I would like to know if I can know the position of the highlighted TR. i.e. if the hightlighted TR is at XX position, I would simply use
divElement.scrollTop = XX

Is this possible or any work-around?

 
Varun Khanna
Ranch Hand
Posts: 1400
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resolved,
the TR attribute I was looking for was "scrollHeight". It gave me the height of that TR.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic