Sorry for the confusion. I'm new at this and have pretty much learned just
through using the book and some examples I've found on-line. I'll try to
show you with code what I'm doing:
Here is my controller code:
----------------------------------------------------------------------
def makeProductGroupLink(productGroup):
link = ElementTree.Element('a', href='/administration/productGroup/%d' %
productGroup.id)
link.text = productGroup.productGroup
return link
pgFields = [('Product Group', makeProductGroupLink), ('Name', 'name')]
class AdministrationController(identity.SecureResource):
require = identity.in_group("admin")
@tg.expose(template='motion.templates.administration.pgDataGrid')
def pgDataGrid(self, *args, **kw):
import time
productGroups = ProductGroup.select(orderBy='productGroup')
return dict(productGroups=productGroups,
productGroupWidget=widgets.DataGrid(fields=pgFields))
----------------------------------------------------------------------
My Template code:
----------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://purl.org/kid/ns#"
py:extends="'../master.kid'">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"
py:replace="''"/>
<title>Admnistration</title>
</head>
<body>
<div id="mainContent">
${productGroupWidget.display(productGroups)}
</div>
</body>
</html>
----------------------------------------------------------------------
Is there a way for me to ask the DataGrid to make the columns sortable by
clicking on the heading? I apologize if this doesn't make any sense, I
really don't know how to describe it any better.
-Jim
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Jorge Vargas
Sent: Thursday, January 04, 2007 1:17 PM
To: [email protected]
Subject: [TurboGears] Re: DataGrid
On 1/4/07, Jim Steil <[EMAIL PROTECTED]> wrote:
I've just started with TurboGears (2 weeks in) and would like to use the
DataGrid widget to display lists for me without having to write a template
for the widget.
if you want to change the structure (read html) you need to extend it.
Yes, I have a template for the page on which the widget
will be displayed, but I would like to avoid having to write a template
for
each list widget.
I don't undestand this, but by subclassing the widget this can be generic.
Is there a way that I can use DataGrid without a widget template and get
the
column sorting to happen automatically?
huh? without a template there is nothing to display therefore there is
no DataGrid
Also, I see that the style of the grid is controlled by grid.css. I can't
find grid.css and was wondering what the best way is to override it. I
want
to change the way that the <a> tag is displayed. Also, can I pass
something
in my column definition that will control the <td> styles applied?
that's what the CSS attibute is a list of CSSLink objects
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---