Name the grids.
grid = SQLFORM.grid(db.table, formname='cadd', formstyle=bootstrap)
On Monday, June 9, 2014 3:47:37 AM UTC-5, Sarbjit wrote:
I am using two grids in my application but I have observed that when I use
Edit/View button for GRID1 and return back (i.e. submit any changes from
Edit option or use back button from View option), then the layout of the
grid is not proper (Data from Grid1 is not seen and only GRID2 data is
seen) and default layout doesn't seems to be loaded.
NOTE :-
Since web2py doesn't supports two grids in one view, I am using LOAD for
one gird and second grid is loaded directly.
Reason, I want to display second grid directly is that I want to customize
the edit function for the grid.
Below is the sample Code
*Views :*
{{extend 'layout.html'}}
{{if grid.view_form:}}
{{=grid}}
{{elif grid.update_form:}}
{{=grid}}
{{else:}}
{{=grid}}
{{=LOAD('default','loadGrid1',ajax=True)}}
{{pass}}
*Controller :*
@auth.requires_login()
def index():
grid =
SQLFORM.grid(query=db.person,csv=False,create=False,deletable=False,paginate=20,sortable=True)
return dict(grid=grid)
def loadGrid1():
grid1 =
SQLFORM.grid(query=db.dog,csv=False,create=False,deletable=False,paginate=20,sortable=True)
return grid1
*Model :*
db.define_table('person',
Field('name'),
Field('countyry'))
db.define_table('dog',
Field('name'),
Field('ownername'))Models :
*SECOND APPROACH *:
Another approach that I have tried was to load both the grids using .load
which could help me to customize the view form (Not sure about this?)
*Controller:*
def test1():
grid1 =
SQLFORM.grid(query=db.person,csv=False,create=False,deletable=False,paginate=20,sortable=True)
return grid1
def test2():
grid2 =
SQLFORM.grid(query=db.dog,csv=False,create=False,deletable=False,paginate=20,sortable=True)
return grid2
*Views:*
{{extend 'layout.html'}}
{{=LOAD('default','test1.load',ajax=True)}}
{{=LOAD('default','test2.load',ajax=True)}}
*.load files (test1/test2)*
{{=grid1}} / {{=grid2}}
Using this approach, both the grids started showing the same data once I
use edit/view on one of the gird (appeared to be random).
My requirement is that I want to display both the grids on the same page
but when a user uses edit/view, data corresponding to a particular grid to
be shown only. Also, in view mode for grid1, I want to display additional
information for which I require the custom grid support as well.
Can someone please help me to resolve this issue.
Thanks
Sarbjit
--
This message is for named person(s) only. It may contain confidential
and/or legally privileged information. No confidentiality or privilege is
waived or lost should mis-transmission occur. If you receive this message
in error, delete it (and all copies) and notify the sender. You must not,
directly or indirectly,use, disclose, distribute, print, or copy any part
of this message if you are not the intended recipient. GAD GROUP
TECHNOLOGY, INC. reserves the right to monitor all e-mail communications
through its networks.
Any views expressed in this message are those of the individual sender,
except where the message states otherwise and the sender is authorized to
state them to be the views of any such entity.
This e-mail has been virus and content scanned by GAD GROUP TECHNOLOGY, INC.
--
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.