tomt wrote:
I wanted to implement the 'extracolumns' feature of SQLTABLE
and the example provided in the source code is:
:param extracolums = [{'label':A('Extra',_href='#'),
'class': '', #class name of the header
'width':'', #width in pixels or %
'content':lambda row, rc: A('Edit',_href='edit/
%s'%row.id),
'selected': False #agregate class selected to this
column
}]
I don't understand this because I didn't define 'row' or 'rc' anywhere
in my controller, but the content definition worked anyways.
With lambda you create a function in-place (without giving it a name).
If you write lambda row, rc : ... you say that you define a function
expecting two parameters: "row" and "rc"
To understand better, you could just as well write the following
equivalent code with a normal function (untested):
def show_content(row, rc):
return A('Edit', _href='edit/%s'%row.id)
extracolums = [{'label':A('Extra',_href='#'),
'class': '',
'width':'',
'content': show_content,
'selected': False
}]