[ 4 posts ]

Todd Smith

YUI Contributor

  • Username: stlsmiths
  • Joined: Thu Nov 05, 2009 10:03 am
  • Posts: 675
  • GitHub: stlsmiths
  • Gists: stlsmiths
  • IRC: t_smith
  • Offline
  • Profile

Paginator and DataTable for YUI 3

Post Posted: Fri Aug 10, 2012 12:43 pm
+0-
I've worked for a little bit towards developing a Paginator to work with DataTable (shout out to everybody on IRC who helped me!). The paginator is designed using YUI's Model and View infrastructure, where the Model keeps track of the housekeeping of the data for the paginator (i.e. # of pages, pages per row, item indices, etc...) and the View provides basic UI rendering and interactions with the paginator Model.

The cool thing about using a Model is that listeners can act on the 'pageChange' events of the model to, er ... change stuff! So although the original target of this was for DataTable, there may be other applications.

A demo of the generic Paginator (Model-View), without connection to anything (i.e. no datatable) is at pagview_demoLinked.html. This example includes something like 16 Paginator Views that are all linked to one shared Model (in this case). So any changes to the page in one View, cascade to all of the others. (Don't really know why one would do this ... but kinda fun to play with :-) ).

Image

The real meat-and-potatoes to this project was a DataTable Paginator. So I applied this Paginator View to a class extension of DataTable that I wrote that adds paging capability to DT (both client-side pagination AND server-side). The DT paginator works with sorting, scrolling and other types of features.

A link to a working demo of server-side pagination via ModelSync.REST is at dt_paginator_REST.html. I'm not link baiting, but there are a few more examples shown at the root of that site if you're interested. Also, it's very difficult to provide server data examples elsewhere other than on a dedicated site.

I may try to submit this for approval to the Gallery in the near future. I've seen a few paginators on the gallery, but didn't see a lot with UI's. Also, the future for an "official" Paginator, and especially one for DataTable seems unclear, so that's why I worked these up.

This is still early work, and I'm looking for any helpful advice people may have.

Thanks,

Todd

PS - Two modules have been added to YUI Gallery for pagination, one is the paginator-view and the other is the datatable-paginator


Last edited by stlsmiths on Thu Mar 07, 2013 2:13 pm, edited 3 times in total.

Satyam

YUI Contributor

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

Re: Paginator and DataTable for YUI 3

Post Posted: Fri Aug 10, 2012 11:15 pm
+0-
Beautiful!

Something that was requested once in a while in YUI2 was to have 'pages' that were alphabetical or any other non-numerical index. Like, if you are looking for a street name starting with S in a 30 page table, you don't need to guess and jump to page 20 and close into it from there.

The YUI2 version never got there because it was designed for numbers from the start and could not be modified. Admittedly there had never been that many requests for that feature, but if it is considered in the design from the start, that is, having non-numerical 'pages' it might be easier to add later.

Of course, an autocomplete works just fine for this, and it might be a better choice. Just something I remembered from YUI2.

Todd Smith

YUI Contributor

  • Username: stlsmiths
  • Joined: Thu Nov 05, 2009 10:03 am
  • Posts: 675
  • GitHub: stlsmiths
  • Gists: stlsmiths
  • IRC: t_smith
  • Offline
  • Profile

Re: Paginator and DataTable for YUI 3

Post Posted: Mon Aug 13, 2012 6:39 am
+0-
Thanks Satyam. I thought about "alphabetized" pagination and considered that was kind of an edge case use for a page-centric, bare-bones paginator. This paginator is based upon using an HTML data attribute (data-pglink="7") for page selector links where for a server requested data it calculates the startIndex and number of records to return / page in the request payload string. I considered the need for a basic DT paginator as paramount, thus why I focused on this approach.

Like many on here, I've done "alphabetized" filtering using a group of toggle buttons that on click send a response with the requested field name to the server. I could imagine a class extension of this paginator that could possibly wrap this capability in, but might take some tinkering.

Todd

Satyam

YUI Contributor

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

Re: Paginator and DataTable for YUI 3

Post Posted: Mon Aug 13, 2012 7:03 am
+0-
It had never been a very frequent request and it can be easily be handled by other means so, better to keep your component simple. It is just that I recalled it when you asked which, BTW, thanks for asking.
  [ 4 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