• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Identifying position of the highlighted row

 
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Resolved,
the TR attribute I was looking for was "scrollHeight". It gave me the height of that TR.
 
A magnificient life is loaded with tough challenges. En garde tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic