alex23 wrote:
> I'm having a problem getting AjaxPaginatedGrid to work. The demo in
> the toolbox works perfectly, but no matter how closely I emulate the
> example source, I cannot get my implementation to paginate. It
> initially fills the grid correctly but doesn't show any other pages
> but the first, with no response from any of the controls. This is with
> TGPaginate 0.1a0.dev-r663 under TG 1.0.2.2.

You are more than likely importing the paginate decorator from
turbogears.  TGPaginate has reimplemented the paginate decorator to
allow multiple paginations.  You need to import paginate from
tgpaginate.controllers.

If you inspect the Ajax requests, you'll see that the pagination
parameters being passed say things like 'tg_paginate_%s_no=5' instead of
'tg_paginate_no=5' - this is the multiple pagination thing happening,
and it is handled in TGPaginate's paginate decorator.

However, I'm also having problems with the AjaxPaginatedGrid.

Firstly, I'm using SQLAlchemy, and TGPaginate only supports SQLObject.
Have any patches been submitted to support SA yet?  Looking at the code,
the changes are fairly trivial, and I'm going to try to add SA support
myself, but I'm not too confident in my ability to do it properly.


That aside, I've discovered what seems to be a pretty big problem with
TGPaginate.

In the AjaxPaginatedGrid kid template, we have:

<a py:if="col.get_option('sortable', False) and getattr(tg, 'paginate',
False)" href="${tg.paginate[value.var_name].get_href(1, col.name,
col.get_option('reverse_order', False))}">${col.title}</a>

This will create the links to sort the grid on a column, if the
tg.paginate attribute is set.

Howeever, this attribute is set by the paginate() decorator, which is no
longer applied to the HTML request that renders the widget - with the
AjaxPaginatedGrid, the JSON request is the one that gets decorated wih
paginate, as shown in your code:

> class Root(controllers.RootController):
> 
>     example_list = [(x,x) for x in range(10,200)]
> 
>     @expose(format='json')
>     @paginate('example_list')
>     def lister(self, *args, **kw):
>         return dict(example_list = self.example_list)
> 
>     @expose(template='project.templates.list')
>     def list(self, *args, **params):
>         grid = AjaxPaginatedGrid(
>             name='list_grid',
>             url='lister',
>             var_name='example_list',
>             fields=[('C1', lambda x: x[0]),
>                 ('C2', lambda x: x[1])]
>             )
>         return dict(grid=grid)

So, when the widget gets rendered, no tg.paginate attribute will be set,
and the sorting links will never be created.

Am I wrong in my analysis?

Has anybody used the AjaxPaginatedGrid successfully, with sorting by
columns and everything, because this problem, if I am right, would seem
to indicate that it's not possible?


Cheers,
-Jonathan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to