File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Identifying position of the highlighted row Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Identifying position of the highlighted row" Watch "Identifying position of the highlighted row" New topic
Author

Identifying position of the highlighted row

Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
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
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
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
 
subject: Identifying position of the highlighted row