0

On a custom control I have a repeat control which iterates over a vector. This repeat control does have a pager bound to it. I want to hide the previous and next links when the pager is on the first or on the last page of the control.

To hide the previous is ofcourse easy >> Add a rendered property to getpageCount() > 0. The next link is a bit of a problem. The pager class does not have a method getCurrentPage(). therefore I can't find out which page I'm currently at on the pager.

Is there someone who does have a fix / idea on how to hide/show the next / previous links on a pager using SSJS?

Cœur
  • 37,241
  • 25
  • 195
  • 267
jjtbsomhorst
  • 1,667
  • 11
  • 28

2 Answers2

3

You can get the number of items in Vector (A) You also know the number of items you are going to display in 1 page of your repeat control(B) So total number of pages will be mod(A/B)+1 . If you are in that page, you can hide the next button.

Mod(modulo) means to skip the decimal part or integer division.

Declan Lynch
  • 3,345
  • 17
  • 36
  • 1
    Thanks for your comment. I hoped I could skip the modulo way and just ask the pager which page it was on. Now I have to feed the pager AND the the repeat with the exact same vector > could be a performance hit? – jjtbsomhorst May 07 '12 at 19:38
0
document.getElementById("#id:pager2}").firstChild.nextSibling.lastChild.lastChild.textContent)

Try the above, Actually above is for getting the value of the Group's value of last element.

I guess that using the client side javascript has more easier than SSJS for manipulating the DOM tree,

Here, We have <previous><Group><Next>, 

So we need to get the second element .And it is a span tag. I am getting the lastChild of lasChild.

Note: Do not hide it by setRendered(true). Because after that DOM tree will loose its children. Use display:none property.

Ramkumar
  • 874
  • 11
  • 27