[web2py] Re: smartgrid: linked_tables=dict(parent=['child'], child=[''])
How did you insert icons for edit in your form I am using SQLFORM.smartgrid and I want my grid to be more bootstrap like. Also I am having problems with displaying my child table fields (They are not displayed :)) Any suggestions? Here is my code workers = db(db.worker.w_organisation == 10).select(db.worker.id, db.worker.w_organisation, db.worker.w_first_name, db.worker.w_last_name,db.worker.w_nick_name,db.worker.w_email,db.worker.w_status,db.worker.w_note).as_list() #Define the query object. Here we are pulling all contacts having date of birth less than 18 Nov 1990 query = ((db.worker.w_organisation == 10) )# (db.worker.w_status==db.status.s_id_s)) #Define the fields to show on grid. Note: (you need to specify id field in fields section in 1.99.2 fields = (db.worker.id,db.worker.w_first_name, db.worker.w_last_name,db.worker.w_nick_name,db.worker.w_email,db.status.s_code,db.worker.w_note) #Define headers as tuples/dictionaries headers = {'worker.id' : 'Id', 'worker.w_first_name' : 'Ime', 'worker.w_last_name' : 'Priimek', 'worker.w_nick_name' : 'Vzdevek', 'worker.w_email' : 'E-posta', 'status.s_code': 'Status', 'worker.w_note' : 'Komentar' } #Let's specify a default sort order on date_of_birth column in grid default_sort_order=[db.worker.w_last_name] form = SQLFORM.smartgrid(db.worker,fields = fields,headers= headers,linked_tables=['status']) And db.py db.define_table('worker', Field('id', type ='id'), Field('w_organisation', type ='integer'), Field('w_user', type ='integer'), Field('w_status', 'reference status'), Field('w_first_name',type='text'), Field('w_last_name',type='text'), Field('w_nick_name',type='text'), Field('w_email',type='text'), Field('w_note',type='text'), migrate=settings.migrate ) db.define_table('status', Field('s_id_s', type ='id'), Field('s_code', type ='text'), Field('s_description', type ='text'), migrate=settings.migrate ) thank you best regards On Friday, September 21, 2012 5:58:05 PM UTC+2, Adi wrote: I'm wondering what to do in this situation? I have self-referencing fields in the child table, and due to that smartgrid display links, which basically can't do anything. I'm trying to eliminate them, but not sure what would be a proper way? Thanks. Simplified code sample: db.define_table('campaign', Field('tbl_uuid', length=64, default=lambda:str(uuid. uuid4())), Field('name','string', label=T('Campaing Name')), format='%(name)s', ) db.define_table('message', Field('tbl_uuid', length=64, default=lambda:str(uuid. uuid4())), Field('name','string', label=T('Name')), Field('campaign_id', 'reference campaign', label=T( 'Campaign')), Field('action_yes_id', 'reference message)', label=T('Action Yes'),), Field('action_no_id', 'reference message)', label=T('Action No')), migrate=True) grid=SQLFORM.smartgrid(Campaign, details=False, links_in_grid=True, linked_tables=['message'], #linked_tables=dict(campaign=['message'], message=['']), links=dict(campaign=[lambda row:(_get_messages(row)) ]), ) Enter code here... -- 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.
[web2py] Re: smartgrid: linked_tables=dict(parent=['child'], child=[''])
I just added the syntax you requested: linked_tables=dict(parent=['child'], child=[]) Please help me test it. On Saturday, 22 September 2012 18:55:57 UTC-5, Adi wrote: If I may rephrase and clarify a question: Is it possible to add control, through dictionary in (smartgrid) linked_tables when will links display? e.g: linked_tables=dict(parent=['child'], child=['']) wishful outcome: display children links for parent table, but don't display any related links for child table. Thanks, Adnan On Friday, September 21, 2012 11:58:05 AM UTC-4, Adi wrote: I'm wondering what to do in this situation? I have self-referencing fields in the child table, and due to that smartgrid display links, which basically can't do anything. I'm trying to eliminate them, but not sure what would be a proper way? Thanks. Simplified code sample: db.define_table('campaign', Field('tbl_uuid', length=64, default=lambda:str(uuid. uuid4())), Field('name','string', label=T('Campaing Name')), format='%(name)s', ) db.define_table('message', Field('tbl_uuid', length=64, default=lambda:str(uuid. uuid4())), Field('name','string', label=T('Name')), Field('campaign_id', 'reference campaign', label=T( 'Campaign')), Field('action_yes_id', 'reference message)', label=T('Action Yes'),), Field('action_no_id', 'reference message)', label=T('Action No')), migrate=True) grid=SQLFORM.smartgrid(Campaign, details=False, links_in_grid=True, linked_tables=['message'], #linked_tables=dict(campaign=['message'], message=['']), links=dict(campaign=[lambda row:(_get_messages(row)) ]), ) Enter code here... --
Re: [web2py] Re: smartgrid: linked_tables=dict(parent=['child'], child=[''])
Thanks Massimo! I'm trying to test it, but got this error bellow: File /Users/adnan/web2py-trunk/gluon/sqlhtml.py, line 2280, in smartgrid linked_tables = linked_tables.get(tablename,[]) UnboundLocalError: local variable 'tablename' referenced before assignment On Sun, Sep 23, 2012 at 5:31 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: I just added the syntax you requested: linked_tables=dict(parent=['**child'], child=[]) Please help me test it. On Saturday, 22 September 2012 18:55:57 UTC-5, Adi wrote: If I may rephrase and clarify a question: Is it possible to add control, through dictionary in (smartgrid) linked_tables when will links display? e.g: linked_tables=dict(parent=['**child'], child=['']) wishful outcome: display children links for parent table, but don't display any related links for child table. Thanks, Adnan On Friday, September 21, 2012 11:58:05 AM UTC-4, Adi wrote: I'm wondering what to do in this situation? I have self-referencing fields in the child table, and due to that smartgrid display links, which basically can't do anything. I'm trying to eliminate them, but not sure what would be a proper way? Thanks. Simplified code sample: db.define_table('campaign', Field('tbl_uuid', length=64, default=lambda:str(uuid .uuid4(**))), Field('name','string', label=T('Campaing Name')), format='%(name)s', ) db.define_table('message', Field('tbl_uuid', length=64, default=lambda:str(uuid .uuid4(**))), Field('name','string', label=T('Name')), Field('campaign_id', 'reference campaign', label=T( 'Campaign')), Field('action_yes_id', 'reference message)', label=T ('Action Yes'),), Field('action_no_id', 'reference message)', label=T('Action No')), migrate=True) grid=SQLFORM.smartgrid(Campaig**n, details=False, links_in_grid=True, linked_tables=['message'], #linked_tables=dict(campaign=[**'message'], message=['']), links=dict(campaign=[lambda row:(_get_messages(row)) ]), ) Enter code here... -- -- Thanks, Adnan video: http://vimeo.com/24653283 --
Re: [web2py] Re: smartgrid: linked_tables=dict(parent=['child'], child=[''])
Can you please try again? On Sunday, 23 September 2012 18:03:48 UTC-5, Adi wrote: Thanks Massimo! I'm trying to test it, but got this error bellow: File /Users/adnan/web2py-trunk/gluon/sqlhtml.py, line 2280, in smartgrid linked_tables = linked_tables.get(tablename,[]) UnboundLocalError: local variable 'tablename' referenced before assignment On Sun, Sep 23, 2012 at 5:31 PM, Massimo Di Pierro massimo@gmail.comjavascript: wrote: I just added the syntax you requested: linked_tables=dict(parent=['**child'], child=[]) Please help me test it. On Saturday, 22 September 2012 18:55:57 UTC-5, Adi wrote: If I may rephrase and clarify a question: Is it possible to add control, through dictionary in (smartgrid) linked_tables when will links display? e.g: linked_tables=dict(parent=['**child'], child=['']) wishful outcome: display children links for parent table, but don't display any related links for child table. Thanks, Adnan On Friday, September 21, 2012 11:58:05 AM UTC-4, Adi wrote: I'm wondering what to do in this situation? I have self-referencing fields in the child table, and due to that smartgrid display links, which basically can't do anything. I'm trying to eliminate them, but not sure what would be a proper way? Thanks. Simplified code sample: db.define_table('campaign', Field('tbl_uuid', length=64, default=lambda:str( uuid.uuid4(**))), Field('name','string', label=T('Campaing Name')), format='%(name)s', ) db.define_table('message', Field('tbl_uuid', length=64, default=lambda:str( uuid.uuid4(**))), Field('name','string', label=T('Name')), Field('campaign_id', 'reference campaign', label=T( 'Campaign')), Field('action_yes_id', 'reference message)', label= T('Action Yes'),), Field('action_no_id', 'reference message)', label=T ('Action No')), migrate=True) grid=SQLFORM.smartgrid(Campaig**n, details=False, links_in_grid=True, linked_tables=['message'], #linked_tables=dict(campaign=[**'message'], message=['']), links=dict(campaign=[lambda row:(_get_messages(row )) ]), ) Enter code here... -- -- Thanks, Adnan video: http://vimeo.com/24653283 --
Re: [web2py] Re: smartgrid: linked_tables=dict(parent=['child'], child=[''])
Works perfect. Thank you Massimo. On Sun, Sep 23, 2012 at 8:16 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Can you please try again? On Sunday, 23 September 2012 18:03:48 UTC-5, Adi wrote: Thanks Massimo! I'm trying to test it, but got this error bellow: File /Users/adnan/web2py-trunk/**gluon/sqlhtml.py, line 2280, in smartgrid linked_tables = linked_tables.get(tablename,[]**) UnboundLocalError: local variable 'tablename' referenced before assignment On Sun, Sep 23, 2012 at 5:31 PM, Massimo Di Pierro massimo@gmail.com wrote: I just added the syntax you requested: linked_tables=dict(parent=['**ch**ild'], child=[]) Please help me test it. On Saturday, 22 September 2012 18:55:57 UTC-5, Adi wrote: If I may rephrase and clarify a question: Is it possible to add control, through dictionary in (smartgrid) linked_tables when will links display? e.g: linked_tables=dict(parent=['**ch**ild'], child=['']) wishful outcome: display children links for parent table, but don't display any related links for child table. Thanks, Adnan On Friday, September 21, 2012 11:58:05 AM UTC-4, Adi wrote: I'm wondering what to do in this situation? I have self-referencing fields in the child table, and due to that smartgrid display links, which basically can't do anything. I'm trying to eliminate them, but not sure what would be a proper way? Thanks. Simplified code sample: db.define_table('campaign', Field('tbl_uuid', length=64, default=lambda:str( uuid.uuid4())), Field('name','string', label=T('Campaing Name')), format='%(name)s', ) db.define_table('message', Field('tbl_uuid', length=64, default=lambda:str( uuid.uuid4())), Field('name','string', label=T('Name')), Field('campaign_id', 'reference campaign', label=T ('Campaign')), Field('action_yes_id', 'reference message)', label =T('Action Yes'),), Field('action_no_id', 'reference message)', label= T('Action No')), migrate=True) grid=SQLFORM.smartgrid(Campaign, details=False, links_in_grid=True , linked_tables=['message'], #linked_tables=dict(campaign=['message'], message=['']), links=dict(campaign=[lambda row:(_get_messages(row )) ]), ) Enter code here... -- --
[web2py] Re: smartgrid: linked_tables=dict(parent=['child'], child=[''])
If I may rephrase and clarify a question: Is it possible to add control, through dictionary in (smartgrid) linked_tables when will links display? e.g: linked_tables=dict(parent=['child'], child=['']) wishful outcome: display children links for parent table, but don't display any related links for child table. Thanks, Adnan On Friday, September 21, 2012 11:58:05 AM UTC-4, Adi wrote: I'm wondering what to do in this situation? I have self-referencing fields in the child table, and due to that smartgrid display links, which basically can't do anything. I'm trying to eliminate them, but not sure what would be a proper way? Thanks. Simplified code sample: db.define_table('campaign', Field('tbl_uuid', length=64, default=lambda:str(uuid. uuid4())), Field('name','string', label=T('Campaing Name')), format='%(name)s', ) db.define_table('message', Field('tbl_uuid', length=64, default=lambda:str(uuid. uuid4())), Field('name','string', label=T('Name')), Field('campaign_id', 'reference campaign', label=T( 'Campaign')), Field('action_yes_id', 'reference message)', label=T('Action Yes'),), Field('action_no_id', 'reference message)', label=T('Action No')), migrate=True) grid=SQLFORM.smartgrid(Campaign, details=False, links_in_grid=True, linked_tables=['message'], #linked_tables=dict(campaign=['message'], message=['']), links=dict(campaign=[lambda row:(_get_messages(row)) ]), ) Enter code here... --