#719: [PATCH] Pagination decorator, easy pagination and sorting
----------------------------------------------------------+-----------------
 Reporter:  Claudio Martinez <[EMAIL PROTECTED]>  |       Owner:  anonymous
     Type:  defect                                        |      Status:  new   
   
 Priority:  normal                                        |   Milestone:        
   
Component:  TurboGears                                    |     Version:        
   
 Severity:  normal                                        |    Keywords:        
   
----------------------------------------------------------+-----------------
 I've made this decorator to be able to paginate resulsets and dictionaries
 without doing any work on the controller.
 You just return a resultset from a Object.select(...) (at this state the
 query hasn't been made yet) or a dict() and pass its name to the paginate
 decorator.
 When you pass a SQLObject ResultSet the decorator won't fetch all the
 results, it will use the .limit() .order() functions to do it's work.
 Which will produce a LIMITed query.

 I've also included a new datagrid (PaginateDataGrid) object with a new
 template that has automatically adds the page list, but you don't need
 this to be able to use it.

 Pagination and sorting can't be made easier if you use PaginateDataGrid,
 you almost have to do nothing but adding the decorator.

 It even works if you are getting filtering info from a POST on your
 controller because it will urlencode all the input_values when you get the
 hrefs for the links.

 When the decorator is used on a controller tg.paginate will be available
 for the template. tg.paginate contains:
 tg.paginate.pages - A list of the pages the paginator will show (ex:
 [4,5,6,7,8])
 tg.paginate.current_page - Current page
 tg.paginate.limit - Current rows per page (you shouldn't need this)
 tg.paginate.page_count - Number of pages
 tg.paginate.order - Current column being sorted
 tg.paginate.reversed - If the current sorting is reversed or not
 tg.paginate.get_href(x) - Returns the href for a link that will show x
 page of the list (ex: <a href="tg.paginate.get_href(1)">Page 1</a> would
 create a link to the first page)

 The decorator takes these parameters:
 @turbogears.paginate(var_name, default_order='', limit=10, max_pages=5,
 allow_limit_override=False)
 var_name - Is the variable that will be paginated
 default_order - Only used when you want to enable sorting, it's the column
 name being sorted by default
 limit - Is the number of rows per page
 max_pages - Is the number of pages that will be returned in
 tg.paginate.pages (the default of 5 when seeing a page number 64
 tg.paginate.pages would be [62,63,64,65,66]

 If you are using the PaginateDataGrid you don't have to worry about most
 of this stuff.

 Check the demo project!

-- 
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/719>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---

Reply via email to