Hi All:

I'm new to turbogears and have a question about dynamic columns in a
DataGrid widget.  I'm adding a column for each instance in a list, and
I'm trying to figure out how to determine what column I'm in when
executing the common lamba/getter.  When creating the column fields
list, I can pass in the column or id of the object, but since the
lambda is actually executed after the loop has completed, I get the
last value (after the full loop has executed) rather than the intended
value (the value created in the loop when the lambda was created)
passed into the expression.

I have something like this:

fields=[]
for policy in policies:
    fields.append( (policy.name, lambda row: getCheckBox(row.name,
row.id, policy.id)) )

ruleGrid = widgets.PaginateDataGrid(fields)
return dict(grid=ruleGrid, data=data)

getCheckBox() is just a function that returns a checkbox widget with
the correct name, etc, that I'm hoping to base off of the policy.id
variable in the for loop listed above.  I'm guessing that there is
some other way to detect what column I'm in when the getCheckBox is
running, but things like self.title don't work (since it looks like
the lambda is getting run in the context of Root rather than Column).

If there's a completely different way I should be doing this, I'd be
glad to hear about it, but I do need it to be dynamic.  I couldn't
find any examples of how to either pass in the column name/id to the
getter function, or how to reference this information from within the
getter.

Any help/pointers are appreciated, Thanks,


Aaron

--~--~---------~--~----~------------~-------~--~----~
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