Goodmornig
I am not a developer but I tryed to modify the modal class I found at
http://linuxapuntes.blogspot.it/2013/03/plugin-modal-bootstrap-web2py.html
It only create a Div based on bootstrap 3 version for modal box, a close
button and a create button.
If you pass an url to create button it also load the content of the url via
"ajax".
Hope it can be a good solution to help load content in boxes . It also
work with SQLFORM, SQLFORM.grid.
In the controller you can set :
def render_grid():
from modal_dialog import Modal
modal = Modal('', '', 'Label Modal', 'Area',class_btn='icon magnifier
icon-edit glyphicon glyphicon-edit')
div_modal = DIV(modal.div_modal(''),modal_view.div_modal(''))
links = [lambda row: DIV(modal.create_btn(URL(f='render_form',
args=row.id)) ,) ]
grid = DIV(SQLFORM.grid(query=query, fields=fields,links=links,
onupdate=False, maxtextlength=200,
user_signature=True,showbuttontext=False,
searchable=True,deletable=False,details=False,editable=False,create =
False, csv =True,sortable=True))
return dict(grid = grid,div_modal=div_modal)
def render_form():
id_args= request.args(0) or redirect(URL('blank_comunicazione'))
form = crud.read(db.table, id_args)
return form
Hope it helps.
Merry Christmas
--
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.
from gluon.html import A, DIV, H3, BUTTON, OPTION, TAG, I, XML, URL
from gluon.sqlhtml import SQLFORM
from gluon.http import HTTP
from gluon import current
import uuid
from gluon.compileapp import LOAD
class Modal(object):
def __init__(self, value, title_btn, title_modal,field, onclose='', class_btn ="icon-plus-sign"):
self.field = field
self.value = value
self.title_btn = title_btn
self.title_modal = title_modal
if self.field:
self.key = str(self.field).replace('.', '_')
else:
self.key = str(uuid.uuid4())
self.class_btn = class_btn
self.modal_id = 'modal_%s' % self.key
self._target = "c_" + self.key
self.request = current.request
self.response = current.response
self.session = current.session
self.onclose = onclose
def btn_close(self):
# Button to trigger modal .
btn_close_modal = BUTTON("Chiudi", **{"_class": "btn",
"_data-dismiss": "modal",
"_aria-hidden": "true",
"_onclick":"$('#contet_modal_%s').empty()"%self.modal_id,
})
return btn_close_modal
def div_modal(self, content_modal):
div_modal = DIV(DIV(DIV(
DIV(
DIV(H3(self.title_modal, _id="myModalLabel"),_class="modal-title"),
_class="modal-header"),
DIV(content_modal, _class="modal-body", _id="contet_modal_%s" %self.modal_id),
DIV(self.btn_close(),_class="modal-footer",),
_class="modal-content"),
_class="modal-dialog modal-lg"),
**{"_id": "%s" % self.modal_id,
"_class": "modal fade",
"_tabindex": "-1",
"_role": "dialog",
"_aria-hidden": "true",
"_aria-labelledby": "myModalLabel"}
)
return div_modal
def create_btn(self,url=''):
btn_show_modal = A(self.title_btn,BUTTON(I(_class=self.class_btn)),_onclick="$('#%s').modal('show')"%self.modal_id, _href=url,cid='contet_modal_%s' % self.modal_id,
**{"_class": "btn btn-link","_role": "button","_title": self.title_btn})
return btn_show_mod