Reputation: 1667
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?
Upvotes: 0
Views: 549
Reputation: 842
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.
Upvotes: 0
Reputation: 46
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.
Upvotes: 3