根据您的个性需求进行定制 先人一步 抢占小程序红利时代
绑定click点击事件
$('.demoTable .layui-btn').on('click', function(){ var type = $(this).data('type'); //注意顶一个括号中的格式,class用.id用#,中间有一个空格 active[type] ? active[type].call(this) : ''; });
此时点击查询按钮,会将keyword这个关键字传到后端,接下来就是自己处理查询关键字业务了。
到目前为止,搜索也有了,分页也有了,对了,分页会自动传到后端page,limit2个值到后台,相当于(pageindex,pagesize)
2、实践,
(1)html页面及javascript代码如下:
{% extends 'common.html'%} {% block content %}
(2)后台代码如下:
@toolsbp.route('/') @toolsbp.route('/index',methods=['GET','POST']) def index(): if request.method=='POST': data={} data['data']='' data['code']=0 data['msg']='查询成功' env=request.form.get('env_tools') if env is None: return json.dumps(data) phone=request.form.get('phone') where='' if phone: where="where phone like '%(phone)s'"%{'phone':'%'+phone+'%'} dbinfo=env_config.ENV_LIST.get(env.upper()).get('sms_platform') dbtool=MysqlPool.MysqlPool(dbinfo.get('db_name')) result=dbtool.getAll("select * from %(table_name)s.sms_send_record %(where)s order by create_time desc limit %(page)d,%(pagesize)d;"%{'where':where,'table_name':dbinfo.get('table_name'),'page':int(request.form.get('page'))-1,'pagesize':int(request.form.get('limit'))}) data['data']=result if result: data['count']=len(result) else: data['count']=0 return json.dumps(data,cls=MysqlPool.DateEncoder) return render_template('tools/index.html')
(3)页面功能如下:
上述就是小编为大家分享的layui数据表格重载实现往后台传参了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。