I just opened a ticket
(http://code.google.com/p/web2py/issues/detail?id=522) and offered a
(probably over-simplistic) mod to sqlhtml.py that would give the
behavior I am looking for. Basically, if None is returned from the
lambda function, the button is not displayed. Works fine for all my
test cases, but will have to see what other issues Massimo sees with my
proposed change.
-Jim
On 11/17/2011 9:51 AM, Cliff wrote:
Jim,
I have to solve a similar puzzle soon. Here's the approach I'm going
to try.
def make_button(this, that):
# dummy_button has the text but is lowlighted without an A helper
if should_return_dummy_button:
return lowlightedbutton
else:
return workingbutton
links = [lambda row: make_button(row.this, row.that. ...)]
On Nov 17, 9:39 am, Jim Steil<[email protected]> wrote:
Hi
I'm using the following to generate custom links for my SQLFORM.smartgrid:
actions = dict()
nextActions = db(db.requisitionStatus.nextFunctionLabel>0).select()
for nextAction in nextActions:
actions[nextAction.requisitionStatusId] =
dict(label=nextAction.nextFunctionLabel,
action=nextAction.nextFunction)
links = [lambda row: A(actions[row.requisitionStatusId]['label'],
_href=URL(actions[row.requisitionStatusId]['action'],args=[row.id]))]
This is all working fine to generate the buttons I need. My problem is
that for some of my requisitionStatus records I don't want any button at
all to appear for that row. I can't figure out how to do it. I've tried:
links = [lambda row: A(actions[row.requisitionStatusId]['label'],
_href=URL(actions[row.requisitionStatusId]['action'],args=[row.id])) if
actions[row.requisitionStatusId]['label'] != '' else None]
but that just generates a button with the text of 'None'. I'm not that
good with lambda functions and was wondering if there was a way that I
could have no button generated somehow.
-Jim