YUILibrary - Open source JavaScript and CSS for building richly interactive software.
Fork YUI on GitHub
  [ 7 posts ]

DirkDiggler

  • Joined: Tue Feb 09, 2010 11:09 am
  • Posts: 5
  • Offline
  • Profile

Paginator: rendering pagination links in separate containers

Post Posted: Tue Feb 09, 2010 2:23 pm
+0-
I'm using version 2.8 of the YUI Paginator in concert with the DataTable. I've been given the requirement to render different sets of pagination navigation widgets in the DataTable footer and header.

The footer pagination needs to look something like this:

Image

The header pagination needs to look something like this:

Image


I got the footer pagination working in pretty short order using a template and by overriding the default SAM classes (i.e. yui-pg-last, yui-pg-first).

I don't know how to tackle the header pagination since multiple templates are not supported by the API. I somehow have to figure out how to make the Paginator.ui.PreviousPageLink and Paginator.ui.NextPageLink render differently depending on the container (header vs footer). As you can see from the screenshots, the Previous/Next page links in the footer don't use an image, but those links need to be rendered using an image in the header.

The API documentation/examples didn't show an obvious way of achieving what I need. The closest I found was this example http://developer.yahoo.com/yui/examples/paginator/pag_manual_render.html in which the render event of the paginator is used to place different pagination widgets into different containers. But I don't see how to manually override the way the Previous/Next links are rendered depending on the container.

I appreciate any help you guys can provide! ;)

Luke Smith

YUI Developer

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 207
  • Location: Sunnyvale
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile

Re: Paginator: rendering pagination links in separate containers

Post Posted: Tue Feb 09, 2010 8:21 pm
+0-
Try the paginator.renderUIComponent( el, id_base ) method
http://developer.yahoo.com/yui/docs/YAH ... IComponent

or the protected paginator._renderTemplate( container, template, id_base ) method
http://developer.yahoo.com/yui/docs/YAH ... erTemplate

You can pass any unique string as the id_base. The Paginator's default id_base is e.g. 'yui-pg0-1' for the second container (1) of the first Paginator on the page (pg0).

HTH

DirkDiggler

  • Joined: Tue Feb 09, 2010 11:09 am
  • Posts: 5
  • Offline
  • Profile

Re: Paginator: rendering pagination links in separate containers

Post Posted: Thu Feb 11, 2010 10:39 am
+0-
Thanks for the quick response. In general, how would one override a protected method such as _renderTemplate?

Luke Smith

YUI Developer

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 207
  • Location: Sunnyvale
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile

Re: Paginator: rendering pagination links in separate containers

Post Posted: Thu Feb 11, 2010 12:20 pm
+0-
You shouldn't need to override it. Just call it with the container you want to populate and the template you want to vivify inside it. It need have no relation to the configured containers or template passed to the Paginator during construction.

But to your question, you override the method as you would any other method:

myPaginator._renderTemplate = function () { /* do you're thing here */ };

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 1265
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • YUI Developer
  • Offline
  • Profile

Re: Paginator: rendering pagination links in separate containers

Post Posted: Thu Feb 11, 2010 12:21 pm
+0-
private and protected members are just a naming convention: they start with an underscore. javaScript knows nothing about them, they are regular methods and can be overridden just line any other.

DirkDiggler

  • Joined: Tue Feb 09, 2010 11:09 am
  • Posts: 5
  • Offline
  • Profile

Re: Paginator: rendering pagination links in separate containers

Post Posted: Thu Feb 11, 2010 2:51 pm
+0-
Ahh..makes perfect sense. Thanks again for your help.

DirkDiggler

  • Joined: Tue Feb 09, 2010 11:09 am
  • Posts: 5
  • Offline
  • Profile

Re: Paginator: rendering pagination links in separate containers

Post Posted: Thu Feb 11, 2010 2:52 pm
+0-
Satyam,

This helps tremendously. As you can tell, I'm still trying to wrap my head around OO constructs in javascript.

Thanks
  [ 7 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum