Hello
I have a view that shows two grids. One is editable one not. Everything ok.
The uneditable has an option view, so user can see all the parameters. Once
in form view there is an edit button and he can edit the values. I want to
prevent that from happening. How can I do that.
This is my code
grid_config200 is the grid that should not be editable in view form
@auth.requires_login()
def config():
user = auth.user_id
org = db(db.auth_user.id ==
user).select(db.auth_user.organization)[0]["organization"]
configSetting200 = ((db.config.co_organisation == org) &
(db.config.co_access_level < 200) )
configSetting200Plus = ((db.config.co_organisation == org) &
(db.config.co_access_level >= 200))
fields_config =(
db.config.co_code,
db.config.co_value,
db.config.co_note
)
db.config.co_organisation.readable = db.config.co_organisation.writable =
False
db.config.co_access_level.readable = db.config.co_access_level.writable =
False
db.config.co_area.writable = False
db.config.co_code.writable = False
# db.config.co_area.readable = db.config.co_area.writable = False
db.config.co_value.widget = SQLFORM.widgets.string.widget
db.config.co_area.widget = SQLFORM.widgets.string.widget
db.config.co_note.widget = SQLFORM.widgets.string.widget
#UNEDITABLE form and data
grid_config200 = SQLFORM.grid(query=configSetting200,
fields=fields_config , searchable=False,create=False,
deletable=False, editable=False, paginate=25, buttons_placement = 'right',
user_signature=False,
maxtextlengths = {'config.co_note' : 256},
showbuttontext = False,formname = 'config200Table',
formargs=dict(message_onsuccess=T('Record updated'),
message_onfailure=T('Form has errors')),
#oncreate=myfunction,
ui = dict(widget='',
header='',
content='',
default='',
cornerall='',
cornertop='',
cornerbottom='',
button='button btn btn-default',
buttontext='buttontext button',
buttonadd='icon plus icon-plus glyphicon glyphicon-plus',
buttonback='icon leftarrow icon-arrow-left glyphicon
glyphicon-arrow-left',
buttonexport='icon downarrow icon-download glyphicon
glyphicon-download',
buttondelete='icon trash icon-trash glyphicon glyphicon-trash',
buttonedit='icon pen icon-pencil glyphicon glyphicon-pencil',
buttontable='icon rightarrow icon-arrow-right glyphicon
glyphicon-arrow-right',
buttonview='icon magnifier icon-zoom-in glyphicon
glyphicon-eye-open',
buttonvidov = 'icon glyphicon glyphicon-euro'
),
exportclasses = dict(csv_with_hidden_cols=False, html = False, tsv =
False, tsv_with_hidden_cols=False, json = False))
grid_config200Plus = SQLFORM.grid(query=configSetting200Plus,
fields=fields_config , searchable=False,create=False,
deletable=False, editable=True, paginate=25, buttons_placement = 'right',
user_signature=False,
maxtextlengths = {'config.co_note' : 256},
showbuttontext = False,formname = 'config200PlusTable',
formargs=dict(message_onsuccess=T('Record updated'),
message_onfailure=T('Form has errors')),
#oncreate=myfunction,
ui = dict(widget='',
header='',
content='',
default='',
cornerall='',
cornertop='',
cornerbottom='',
button='button btn btn-default',
buttontext='buttontext button',
buttonadd='icon plus icon-plus glyphicon glyphicon-plus',
buttonback='icon leftarrow icon-arrow-left glyphicon
glyphicon-arrow-left',
buttonexport='icon downarrow icon-download glyphicon
glyphicon-download',
buttondelete='icon trash icon-trash glyphicon glyphicon-trash',
buttonedit='icon pen icon-pencil glyphicon glyphicon-pencil',
buttontable='icon rightarrow icon-arrow-right glyphicon
glyphicon-arrow-right',
buttonview='icon magnifier icon-zoom-in glyphicon
glyphicon-eye-open',
buttonvidov = 'icon glyphicon glyphicon-euro'
),
exportclasses = dict(csv_with_hidden_cols=False, html = False, tsv =
False, tsv_with_hidden_cols=False, json = False))
return dict(grid_config200 = grid_config200, grid_config200Plus =
grid_config200Plus)
--
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.