multiple SQLFORM.grid on tabs

225 views
Skip to first unread message

Yebach

unread,
Aug 11, 2014, 10:03:56 AM8/11/14
to web...@googlegroups.com
Hello

I am trying to create a view where I have tabs and each tab has its own view.
All tabs are included into main view. lets call it settings.

In settings there are tabs for user to insert workers into tables, posts, etc etc. all the (un)necessary stuff.

For each I would like to use SQLFORM.grid. It already works for inserting workers, but how to add new ones??

I guess in controller I have to create function for each table (form.grid) and for each I have to create new view (html)??

And what function to create for main view? - Basically it should show data for workers but this way all I get is workers SQLform.grid

Is this it even possible.

Any guideliness would be nice

Thank you

some code

main view 

<ul class="nav nav-tabs">
<li class="active"><a href="#zaposleni" data-toggle="tab">{{=T('Delavci')}}</a></li>
<li><a href="#turnusi" data-toggle="tab">{{=T('Turnusi')}}</a></li>
</ul>

<div class="tab-content">
<div class="tab-pane active" id="visual">
{{include '../views/settings/workers.html'}}
</div>
<div class="tab-pane" id="turnusi">
{{include '../views/settings/turnusi.html'}}
</div>
</div>
<div>
<div class="col-md-2">
<div id="navVisual" data-spy="affix" data-offset-top="60">
<ul class="nav nav-pills nav-stacked" style="margin-top: 10px;">
<li><a href="#SifrantDelavcev">{{=T('Delavci')}}</a></li>
<li><a href="#unkn">{{=T('Turnusi')}}</a></li>
</ul>
</div>
</div>
</div>

My view for workers

<div class="row" >
<div id="mainContainer" class="col-md-10">
<h4><b>{{=T('Šifrant delavcev')}}</b></h4>
<div class="flash">{{=response.flash}}</div>
<div id="SifrantDelavcev" class="well well-sm">
{{=grid}}
</div>
</div>
</div

my view for turnusi

<div class="row" >
<div id="mainContainer" class="col-md-10">
<h4><b>{{=T('Šifrant turnusov')}}</b></h4>
<div class="flash">{{=response.flash}}</div>
{{=grid}}
</div>
</div>


and for both i have fucntions in controller


Cliff Kachinske

unread,
Aug 11, 2014, 10:58:34 AM8/11/14
to web...@googlegroups.com
I would just use ajax or LOAD.

If you really want to use grid, something like this might work.

In the view:
<div id=tab_0>
{{=form_0}}
</div>


<div id=tab_1>
{{=form_1}}
</div>


<div id=tab_...>
{{=form_...}}
</div>

In the controller:
def some_func():


    form_0
= SQLFORM.grid(whatever)
    form_1
= SQLFORM.grid(whatever_else)
    form_
... = SQLFORM.grod(yet_other)


return dict(form_0=form_0, form_1=form_1, form_...=form_...)

Vid Ogris

unread,
Aug 12, 2014, 3:10:38 AM8/12/14
to web...@googlegroups.com
Thanks for reply

I get both grids but they are not in different tabs but both in the same
and in addition, when I open view or edit option I get double view for one record?


--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/cB5pLIi9N6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Lep pozdrav 

Vid Ogris


Massimo Di Pierro

unread,
Aug 12, 2014, 1:41:16 PM8/12/14
to web...@googlegroups.com
You cannot have multiple grids in one page because they use the url args to set their parameters. Unless you load the grid separately via ajax.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Vid Ogris

unread,
Aug 12, 2014, 2:23:04 PM8/12/14
to web...@googlegroups.com
How can I do that? Load via Ajax?


To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages