Another thing when you are using SQLFORM.grid and .smartgrid this notation
is required:

db.dog.owner.represent = lambda value, row: db.person(value).name

*because this notation raise an error:*


db.dog.owner.represent = lambda value: db.person(value).name

(take this in consideration or you are going to get mad)

2011/8/26 Martín Mulone <mulone.mar...@gmail.com>

> db.dog.owner.represent = lambda value, row: db.person(value).name
>
> Value is the value of the current field, in this example dog owner is an id 
> of the person for example "1", so to display person name I have to pass this 
> value to search a person with this id: db.person(value).name.
>
> Row is the all row of the current record, perhaps for this example is not 
> need it. But for example suppose I have to list dogs name blast his age.
>
>
> db.dog.name.represent = lambda value, row: '%s (%s)'%(value, row.age)
>
> Result:
>
> Name
> -------------------
> doggy (2)
> gog (12)
>
>
>
> 2011/8/26 Johann Spies <johann.sp...@gmail.com>
>
>> Thanks.
>>
>> It will be very helpful if somebody can update these lines in the book
>> because  it still not clear to me how to use the new syntax in each of these
>> instances.  I still do not know how 'record' is defined here.
>>
>> db.mytable.name.represent = lambda name: name.capitalize()
>>
>>
>>
>> db.mytable.other_id.represent = lambda id: db.other(id).myfield
>>
>>
>>
>>
>> db.mytable.some_uploadfield.represent = lambda value: \
>>
>>
>>
>>
>>     A <http://web2py.com/book/default/docstring/A>('get it', _href=URL 
>> <http://web2py.com/book/default/docstring/URL>('download', args=value))
>>
>>
>>
>>
>> I have no idea how to use 'record' e.g. in your example of the new grid:
>>
>>
>> db.dog.owner.represent = lambda x,record: db.person[x].name
>>
>>
>> is not correct
>>
>> Regards
>> Johann
>> --
>>  May grace and peace be yours in abundance through the full knowledge of
>> God and of Jesus our Lord!  His divine power has given us everything we need
>> for life and godliness through the full knowledge of the one who called us
>> by his own glory and excellence.
>>                                                     2 Pet. 1:2b,3a
>>
>>
>
>
> --
>  http://martin.tecnodoc.com.ar
>
>


-- 
 http://martin.tecnodoc.com.ar

Reply via email to