In other words... Is there a way to show a total of the child table in each 
row of the master table (grid) ??


Thanks


On Tuesday, January 19, 2016 at 5:52:51 PM UTC-2, Marcello wrote:
>
> Yes. I can see the tables...
> And yes... I can call the function.. It's working OK...
>
> Thanks...
>
> On Tue, Jan 19, 2016 at 4:39 PM, Fabiano Almeida wrote:
>
>> Hi Marcello,
>>
>> Can you see your tables in appadmin?
>>
>> And your lambda, you can create and call function to count in konsulta's 
>> table and return the number.
>>
>> Field.Virtual('total', lambda row: kontagem(row.id))
>>
>>
>> Att.,
>>
>> Fabiano.
>>
>> 2016-01-19 15:09 GMT-02:00 Marcello :
>>
>>> Hello,
>>>
>>> I have a one to many configuration, using mysql database.
>>> I want to show a grid with the "one" table, and for each row, count the 
>>> "many".
>>>
>>> For that I created a total virtual field.
>>> It works OK in the shel, for example....
>>>
>>> But when I call the SQLFORM.grid I get an error....
>>>
>>> Why do this happen ???
>>> Is there a way to get this ??
>>>
>>>
>>> Thanks
>>> Marcello
>>>
>>> db.define_table(
>>>     'trabalho',
>>>     Field('descricao','string'),
>>>     Field.Virtual('total', lambda row: row.trabalho.konsulta.count()),
>>>     )
>>>
>>> db.define_table(
>>>     'konsulta',
>>>     Field('trabalho_id', 'reference trabalho'),
>>>     Field('name','string'),
>>>     )
>>>
>>>
>>> I want to show a grid with:
>>> grid = SQLFORM.grid(db.trabalho, editable=True, create=False, 
>>> deletable=False)
>>>
>>> When I call it, I get:
>>> <type 'exceptions.KeyError'>
>>>
>>>
>>>
>>> -- 
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to web2py+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to