本文整理汇总了Python中gluon.sqlhtml.SQLFORM.search_menu方法的典型用法代码示例。如果您正苦于以下问题:Python SQLFORM.search_menu方法的具体用法?Python SQLFORM.search_menu怎么用?Python SQLFORM.search_menu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluon.sqlhtml.SQLFORM
的用法示例。
在下文中一共展示了SQLFORM.search_menu方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: grid
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import search_menu [as 别名]
#.........这里部分代码省略.........
elif request.vars.records and not isinstance(
request.vars.records,list):
request.vars.records=[request.vars.records]
elif not request.vars.records:
request.vars.records=[]
session['_web2py_grid_referrer_'+formname] = url2(vars=request.vars)
console = DIV(_class='web2py_console %(header)s %(cornertop)s' % ui)
error = None
search_actions = DIV(_class='web2py_search_actions')
if create:
search_actions.append(gridbutton(buttonclass='buttonadd',
buttontext=T('Add'), buttonurl=url(args=['new',tablename])))
console.append(search_actions)
# if create:
# add = gridbutton(
# buttonclass='buttonadd',
# buttontext='Add',
# buttonurl=url(args=['new',tablename]))
# if not searchable:
# console.append(add)
else:
add = ''
if searchable:
sfields = reduce(lambda a,b:a+b,
[[f for f in t if f.readable] for t in tables])
if isinstance(search_widget,dict):
search_widget = search_widget[tablename]
if search_widget=='default':
search_menu = SQLFORM.search_menu(sfields)
search_widget = lambda sfield, url: CAT(add,FORM(
INPUT(_name='keywords',_value=request.vars.keywords,
_id='web2py_keywords',_onfocus="jQuery('#w2p_query_fields').change();jQuery('#w2p_query_panel').slideDown();"),
INPUT(_type='submit',_value=T('Search'),_class="btn"),
INPUT(_type='submit',_value=T('Clear'),_class="btn",
_onclick="jQuery('#web2py_keywords').val('');"),
_method="GET",_action=url),search_menu)
form = search_widget and search_widget(sfields,url()) or ''
console.append(form)
keywords = request.vars.get('keywords','')
try:
if callable(searchable):
subquery = searchable(sfields, keywords)
else:
subquery = SQLFORM.build_query(sfields, keywords)
except RuntimeError:
subquery = None
error = T('Invalid query')
else:
subquery = None
if subquery:
dbset = dbset(subquery)
try:
if groupby:
nrows = len(dbset.select(*groupfields, join=join, left=left, groupby=groupby, having=having, cacheable=True))
elif left or join:
nrows = dbset.select('count(*)',join=join,left=left, cacheable=True).first()['count(*)']
# if left or groupby:
# c = 'count(*)'
# nrows = dbset.select(c,left=left,cacheable=True,