本文整理汇总了Python中gluon.sqlhtml.SQLFORM.grid方法的典型用法代码示例。如果您正苦于以下问题:Python SQLFORM.grid方法的具体用法?Python SQLFORM.grid怎么用?Python SQLFORM.grid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluon.sqlhtml.SQLFORM
的用法示例。
在下文中一共展示了SQLFORM.grid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: grid
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def grid(self):
def get_unique(form):
slug = IS_SLUG()(form.vars.f_title)[0]
form.vars.f_slug_key = slug
fields = [self.db.t_page.f_title, self.db.t_page.f_lang_code, self.db.t_page.f_tags, self.db.t_page.f_is_active]
links = [
lambda row: A('Preview', _target='_blank', _class="btn-success btn-mini", _href=URL('page', 'show', args=[str(row.id)]))]
grid = SQLFORM.grid(self.db.t_page,
ui='web2py',
fields=fields,
#orderby=fields[-2],
links=links,
csv=False,
searchable=True,
create=True,
details=True,
editable=True,
deletable=True,
onvalidation=get_unique,
#oncreate=get_unique,
)
return grid
示例2: get_form
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def get_form(self, query,field_id,orderby,fields=None,headers={},frm_type="view",priority="0,1",create=True):
gform = SQLFORM.grid(query=query, field_id=field_id, fields=fields, headers=headers,
orderby=orderby, paginate=20, maxtextlength=25,
searchable=False, csv=False, details=False, showbuttontext=False,
create=create, deletable=False, editable=True, selectable=False,
ignore_common_filters=False)
if type(gform[1][0][0]).__name__!="TABLE":
if frm_type in ("edit","new"):
gform = self.set_input_form(gform)
if frm_type == "edit":
gform[1][0][0] = ""
else:
htable = gform.elements("div.web2py_htmltable")
if len(htable)>0:
self.set_htmltable_style(htable[0][0],"form_search",priority)
htable[0][0]["_width"]="100%"
counter = gform.elements("div.web2py_counter")
if len(counter)>0:
if counter[0][0]==None:
counter[0][0] = ""
if gform[len(gform)-1]["_class"].startswith("web2py_paginator"):
pages = gform[len(gform)-1].elements("a")
for i in range(len(pages)):
pages[i]["_data-ajax"] = "false"
return gform
示例3: confirm_vacation
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def confirm_vacation():
db.co_vacation.id.readable = False
subordinates = db(db.co_employee.superior == db(db.co_employee.authuser == auth.user.id).select(db.co_employee.id).first().id).select()
vacations = SQLFORM.grid(db.co_vacation.employee.belongs(subordinates) & (db.co_vacation.status == 'Awaiting'), orderby = ~db.co_vacation.startdate,
create = False, details = False, editable = False, deletable = False,
links = [lambda row: A(T('Accept'), _href = URL('accept_vacation', args = row.id), _class = 'btn'),
lambda row: A(T('Reject'), _href = URL('reject_vacation', args = row.id), _class = 'btn')])
return locals()
示例4: grid
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def grid(self):
grid = SQLFORM.grid(self.db.t_post,
formstyle='table2cols',
csv=False,
searchable=False,
create=True,
details=True,
editable=True,
deletable=True,
)
return grid
示例5: groups
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def groups():
if "new" in request.args:
redirect(URL("group", args=("new")))
elif "edit" in request.args:
redirect(URL("group", args=("edit", request.args(2))))
elif "view" in request.args:
redirect(URL("group", args=("view", request.args(2))))
else:
db.auth_group.id.readable = False
grid = SQLFORM.grid(db.auth_group, orderby=db.auth_group.role, maxtextlength=50)
return locals()
示例6: users
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def users():
if "new" in request.args:
redirect(URL("user", args=("new")))
elif "edit" in request.args:
redirect(URL("user", args=("edit", request.args(2))))
elif "view" in request.args:
redirect(URL("user", args=("view", request.args(2))))
else:
db.auth_user.id.readable = False
grid = SQLFORM.grid(db.auth_user, orderby=db.auth_user.last_name, maxtextlength=50)
return locals()
示例7: memberships
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def memberships():
if "new" in request.args:
redirect(URL("membership", args=("new")))
elif "edit" in request.args:
redirect(URL("membership", args=("edit", request.args(2))))
elif "view" in request.args:
redirect(URL("membership", args=("view", request.args(2))))
else:
db.auth_membership.id.readable = False
grid = SQLFORM.grid(db.auth_membership, maxtextlength=50)
return locals()
示例8: list_task
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def list_task():
if 'new' in request.args:
redirect(URL('create_task', args = ('new', request.args(0))))
elif 'edit' in request.args:
redirect(URL('update_task', args = ('edit', request.args(3))))
elif 'view' in request.args:
redirect(URL('view_task', args = ('view', request.args(3))))
else:
projectid = request.args(0, cast = int)
projectname = db.co_project(projectid).name
db.co_task.id.readable = False
tasks = SQLFORM.grid(db.co_task.project == projectid, orderby = ~db.co_task.modified_on, args = [projectid], maxtextlength = 50, user_signature = False)
return locals()
示例9: list_project
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def list_project():
if 'new' in request.args:
redirect(URL('create_project', args = ('new')))
elif 'edit' in request.args:
redirect(URL('update_project', args = ('edit', request.args(2))))
elif 'view' in request.args:
redirect(URL('view_project', args = ('view', request.args(2))))
else:
db.co_project.id.readable = False
db.co_project.budget.readable = False
db.co_project.managers.readable = False
db.co_project.architects.readable = False
db.co_project.analysts.readable = False
db.co_project.programmers.readable = False
db.co_project.testers.readable = False
projects = SQLFORM.grid(db.co_project, orderby = ~db.co_project.startdate, maxtextlength = 50)
return locals()
示例10: list_employee
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def list_employee():
if 'new' in request.args:
redirect(URL('create_employee', args=('new')))
elif 'edit' in request.args:
redirect(URL('update_employee', args=('edit', request.args(2))))
elif 'view' in request.args:
redirect(URL('view_employee', args=('view', request.args(2))))
else:
db.co_employee.id.readable = False
db.co_employee.came.readable = False
db.co_employee.gone.readable = False
db.co_employee.address.readable = False
db.co_employee.superior.readable = False
db.co_employee.renumeration.readable = False
db.co_employee.cyvacationdays.readable = False
db.co_employee.pyvacationdays.readable = False
employees = SQLFORM.grid(db.co_employee, orderby = db.co_employee.lastname)
return locals()
示例11: list_vacation
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def list_vacation():
if 'new' in request.args:
redirect(URL('create_vacation', args=('new')))
elif 'edit' in request.args:
redirect(URL('update_vacation', args=('edit', request.args(2))))
elif 'view' in request.args:
redirect(URL('view_vacation', args=('view', request.args(2))))
else:
db.co_vacation.id.readable = False
db.co_vacation.employee.readable = False
vacations = SQLFORM.grid(db.co_vacation.created_by == auth.user.id, orderby = ~db.co_vacation.startdate,
editable = lambda row: (row.status == 'Awaiting'), deletable = lambda row: (row.status == 'Awaiting'))
totalthisyear = db(db.co_employee.authuser == auth.user.id).select().first().cyvacationdays
totallastyear = db(db.co_employee.authuser == auth.user.id).select().first().pyvacationdays
previousyearleft = totallastyear - (db((db.co_vacation.startdate.year() == datetime.date.today().year - 1) & (db.co_vacation.status == 'Accepted')).select(db.co_vacation.totaldays.sum()).first()[db.co_vacation.totaldays.sum()] or 0)
utilized = db((db.co_vacation.created_by == auth.user.id) & (db.co_vacation.status == 'Accepted')).select(db.co_vacation.totaldays.sum()).first()[db.co_vacation.totaldays.sum()]
return locals()
示例12: grid
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def grid(self):
fields = [self.db.t_apps.f_title, self.db.t_apps.f_is_active, self.db.t_apps.f_order_id]
fields[1].represent = lambda value, row: SPAN('active', _class='label label-success') \
if value == True else SPAN('disable', _class='label label-danger')
links = [
lambda row: A('Enable', _class="btn-success btn-mini", callback=URL('apps', 'action', args=[str(row.id), 'enable']))
if row.f_is_active == False else "",
lambda row: A('Disable', _class="btn-danger btn-mini", callback=URL('apps', 'action', args=[str(row.id), 'disable']))
if row.f_is_active == True else "",]
self.db.t_apps.f_thumbnail.readable = True
grid = SQLFORM.grid(self.db.t_apps,
ui='web2py',
fields=fields,
links=links,
csv=False,
searchable=True)
return grid
示例13: grid
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def grid(self):
links = [
lambda row: A('Preview', _target='_blank', _class="btn-success btn-mini", _href=URL('template', 'show', args=[str(row.id)]))]
fields = [self.db.t_email_template.f_template_key, self.db.t_email_template.f_lang_code, self.db.t_email_template.f_attachment_file]
grid = SQLFORM.grid(self.db.t_email_template,
ui='web2py',
#linked_tables=linked_tables,
fields=fields,
#orderby=fields[-2],
links=links,
csv=False,
searchable=False,
create=True,
details=True,
editable=True,
deletable=True,
#onvalidation=get_unique,
#oncreate=get_unique,
)
return grid
示例14: test_grid
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def test_grid(self):
grid_form = SQLFORM.grid(self.db.auth_user)
self.assertEqual(grid_form.xml()[:4], b'<div')
示例15: do_grid_select
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import grid [as 别名]
def do_grid_select(self):
response = current.response
request = current.request
T = current.T
action = 'select'
response.title = T(self.table._plural)
response.subtitle = T('Listing')
response.breadcrumbs = response.title
exportclasses = dict(
csv_with_hidden_cols=False,
json=False,
tsv_with_hidden_cols=False,
tsv=False
)
links = self.grid_links()
def _table_or_query():
query = self.customize.on_grid_query(self)
if not query:
query = self.table
return query
self.customize.on_before_init(self, action)
grid = SQLFORM.grid(
_table_or_query(),
fields=self.customize.on_fields_list(self, action),
#field_id=None,
#left=None,
#headers={},
orderby=self.customize.on_grid_orderby(self),
#groupby=None,
#searchable=True,
#sortable=True,
#paginate=20,
deletable=False,
editable=False,
details=False,
#selectable=None,
#create=True,
#csv=True,
links=links,
#links_in_grid=True,
#upload='<default>',
#args=[],
#user_signature=True,
#maxtextlengths={},
maxtextlength=30,
#onvalidation=None,
#oncreate=None,
#onupdate=None,
#ondelete=None,
#sorter_icons=(XML('↑'), XML('↓')),
ui=ONXFORM.ui,
#showbuttontext=True,
_class="table table-condensed table-hover resp-table",
#formname='web2py_grid',
#search_widget='default',
#ignore_rw = False,
#formstyle = 'table3cols',
exportclasses=exportclasses,
#formargs={},
#createargs={'origin':'select'},
#editargs={},
#viewargs={},
#buttons_placement = 'right',
#links_placement = 'right',
)
self.customize.on_after_init(self, grid, action)
return dict(content=grid)