sortable paginate

1 view
Skip to first unread message

Lukasz Szybalski

unread,
Jun 5, 2008, 12:38:24 PM6/5/08
to TurboGears
Hello,
I just wanted to add sortable option to paginatedatagrid and for some
reason I get:

Traceback (most recent call last):
File "start-unis.py", line 15, in ?
start()
File "/home/xxx/turbogears/xxx/xxx/commands.py", line 52, in start
from xxx.controllers import Root
File "/home/xx/turbogears/xxx/xxx/controllers.py", line 58, in ?
activexxxx_datagrid = PaginateDataGrid(fields=[
File "/usr/local/pythonenv/BASELINE/lib/python2.4/site-packages/TurboGears-1.0.4.4-py2.4.egg/turbogears/widgets/meta.py",
line 145, in widget_init
func(self, *args, **kw)
File "/usr/local/pythonenv/BASELINE/lib/python2.4/site-packages/TurboGears-1.0.4.4-py2.4.egg/turbogears/widgets/datagrid.py",
line 85, in __init__
self.columns = self._parse(self.fields)
File "/usr/local/pythonenv/BASELINE/lib/python2.4/site-packages/TurboGears-1.0.4.4-py2.4.egg/turbogears/widgets/datagrid.py",
line 124, in _parse
title, name_or_f = col
ValueError: too many values to unpack


sortable=dict(sortable=True)

activexxxx_datagrid = PaginateDataGrid(fields=[
('ID#', 'NO_0',sortable),
#('Ref#', REF_NO'),
('Issue Date', 'ISSUE_DATE'),
])

Any ideas why this might be happening?

Lucas

Jim Steil

unread,
Jun 5, 2008, 1:58:12 PM6/5/08
to turbo...@googlegroups.com
Does it help if you drop the comma after 'ISSUE_DATE')? Or, is that
just a typo in the email?

-Jim

Lukasz Szybalski

unread,
Jun 5, 2008, 2:18:18 PM6/5/08
to turbo...@googlegroups.com
You can have it or you can take it away. It should work both way.


I just created a new project and i am doing something wrong or its a bug.

from turbogears.widgets import PaginateDataGrid

sortable = dict(sortable=True)

mytable_grid = PaginateDataGrid(name='my big results',
fields=[
('ID', 'id', sortable),
('Groupname', 'group_name'),
('Last Name', 'last_name', sortable),
('Members', 'num_members', sortable)
])

class Root(controllers.RootController):
@expose(template="pag.templates.welcome")
@paginate('myresults',limit=50,default_order='last_name')
# @identity.require(identity.in_group("admin"))
def index(self):
import time
# log.debug("Happy TurboGears Controller Responding For Duty")
flash("Your application is now running")
myresults=[(6,100,'szyb','ll'),(2,300,'szybalsk','kk')]
return dict(now=time.ctime(),myresults=myresults,mytablegrid=mytable_grid)

and in template
<p><span py:content="mytablegrid(myresults)">My Grid will show here.</span></p>


Lucas

Jim Steil

unread,
Jun 5, 2008, 2:28:43 PM6/5/08
to turbo...@googlegroups.com
Lucas:

Here is what I'd use:

mytable_grid = PaginateDataGrid(name='my big results',
    fields=[
        PaginateDataGrid.Column('ID', 'id', 'columnHeaderToDisplay', options=dict(sortable=True)),
        PaginateDataGrid.Column('Groupname', 'group_name', 'columnHeaderToDisplay', options=dict(sortable=True)),
        PaginateDataGrid.Column('Last Name', 'last_name', 'columnHeaderToDisplay', options=dict(sortable=True)),
        PaginateDataGrid.Column('Members', 'num_members', 'columnHeaderToDisplay', options=dict(sortable=True))
])
    -Jim

Christoph Zwerschke

unread,
Jun 5, 2008, 4:24:40 PM6/5/08
to turbo...@googlegroups.com
Lukasz Szybalski schrieb:

> sortable=dict(sortable=True)
>
> activexxxx_datagrid = PaginateDataGrid(fields=[
> ('ID#', 'NO_0',sortable),
> #('Ref#', REF_NO'),
> ('Issue Date', 'ISSUE_DATE'),
> ])
>
> Any ideas why this might be happening?

I think this works only with the svn head of the 1.0 branch.
Older TG versions allow only 2-tuples or PaginateDataGrid.Column
instances here.

-- Chris

Reply all
Reply to author
Forward
0 new messages