Hello Anthony,
Thanks for your reply. I am trying to pass *itemid* to the component. How
do I do that?
Basically imagine a model like>
db.define_table('person',
Field('firstname'),
Field('lastname'), format='%(firstname)s %(lastname)s')
db.define_table('dog',
Field('name'),
Field('owner',db.person))
and what I want to generate is a view where there is every person listed
and each person has a grid below with the dogs it owns. I figured
components would be the best approach, but I don't know how to pass a
parameter (the owner ID, for the example model) to the component.
Thanks,
Clara
El domingo, 14 de diciembre de 2014 23:43:24 UTC-3, Anthony escribió:
>
> The grid makes use of URL args, so if the base URL of the grid action also
> includes args, you must tell the grid to preserve those extra-grid args via
> its "args" argument:
>
> form = SQLFORM.grid(db.address.client == itemid, args=request.args[:1])
>
> Anthony
>
> On Sunday, December 14, 2014 2:54:06 PM UTC-5, clara wrote:
>>
>> Hello,
>>
>> I would like to see an example of a component with an argument. I tried
>> it with no luck, If I define the component without arguments it works fine
>> but if I add an argument loading the page that has the component leads to
>> some kind of infinite recursion. Any help on this would be appreciated. To
>> be more explicit:
>>
>> in the controller:
>> @auth.requires_login()
>> def component_action():
>> itemid = request.args(0)
>> form = SQLFORM.grid(db.address.client==itemid)
>> return dict(form=form)
>>
>> in views:
>> I create a "component_action.load":
>>
>> <div class="manage_things2">
>> {{=form}}
>> </div>
>>
>> I use the component in another action adding to the action's HTML:
>> {{=LOAD('default','component_action.load',args=2, ajax=True)}}
>>
>> Is there anything awefully wrong in this?
>>
>> I will appreciate your help. Thanks!
>>
>> Clara
>>
>>
>>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.