這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)?lái)有關(guān)layui數(shù)據(jù)表格重載實(shí)現(xiàn)往后臺(tái)傳參,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
十余年的渭源網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。全網(wǎng)營(yíng)銷推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整渭源建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。成都創(chuàng)新互聯(lián)從事“渭源網(wǎng)站設(shè)計(jì)”,“渭源網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。1、網(wǎng)上的代碼:
<div class="demoTable"> 搜索商戶: <div class="layui-inline"> <input class="layui-input" name="keyword" id="demoReload" autocomplete="off"> </div> <button class="layui-btn" data-type="reload">搜索</button></div> 在js加入初始化代碼和定義加載方法 layui.use('table', function(){ var table = layui.table; //方法級(jí)渲染 table.render({ elem: '#LAY_table_user' ,url: 'UVServlet' ,cols: [[ {checkbox: true, fixed: true} ,{field:'id', title: 'ID', width:80, sort: true, fixed: true} ,{field:'aid', title: '商戶', width:80, sort: true} ,{field:'uv', title: '訪問(wèn)量', width:80, sort: true,edit:true} ,{field:'date', title: '日期', width:180} ,{field:'datatype', title: '日期類型', width:100} ]] ,id: 'testReload' ,page: true ,height: 600 }); var $ = layui.$, active = { reload: function(){ var demoReload = $('#demoReload'); table.reload('testReload', { where: { keyword: demoReload.val() } }); } }; )};
綁定click點(diǎn)擊事件
$('.demoTable .layui-btn').on('click', function(){ var type = $(this).data('type'); //注意頂一個(gè)括號(hào)中的格式,class用.id用#,中間有一個(gè)空格 active[type] ? active[type].call(this) : ''; });
此時(shí)點(diǎn)擊查詢按鈕,會(huì)將keyword這個(gè)關(guān)鍵字傳到后端,接下來(lái)就是自己處理查詢關(guān)鍵字業(yè)務(wù)了。
到目前為止,搜索也有了,分頁(yè)也有了,對(duì)了,分頁(yè)會(huì)自動(dòng)傳到后端page,limit2個(gè)值到后臺(tái),相當(dāng)于(pageindex,pagesize)
2、實(shí)踐,
(1)html頁(yè)面及javascript代碼如下:
<!--index.html內(nèi)容如下--> {% extends 'common.html'%} {% block content %} <div class="layui-row"> <form class="layui-form layui-col-md12 we-search" id="form_gen_data"> <div class="layui-inline"> <label class="layui-form-label">手機(jī)號(hào)</label> <input class="layui-input" placeholder="手機(jī)號(hào)" name="phone" id="phone"> </div> <div class="layui-inline"> <label class="layui-form-label">身份證</label> <input class="layui-input" placeholder="身份證" name="idno" id="idno"> </div> <div class="layui-inline"> <label class="layui-form-label">姓名</label> <input class="layui-input" placeholder="姓名" name="name" id="name"> </div> <div class="layui-inline"> <label class="layui-form-label">crfuid</label> <input class="layui-input" placeholder="crfuid" name="crfuid" id="crfuid"> </div> </form> </div> <div class="weadmin-block"> <button class="layui-btn" id="query_extra" >擴(kuò)展功能</button> <button class="layui-btn" id="query_thumb">開始查詢</button> <button class="layui-btn" id="query_limit">額度查詢</button> <button class="layui-btn" id="query_member">會(huì)員查詢</button> <button class="layui-btn" id="query_account">賬戶查詢</button> <button class="layui-btn" id="query_sms" οnclick="return false;" data-type="reload">短信驗(yàn)證碼查詢</button> <div class="layui-collapse" lay-accordion> <div class="layui-colla-item"> <h3 class="layui-colla-title">擴(kuò)展功能</h3> <div class="layui-colla-content"> {% for business in common_business %} <button class="layui-btn layui-btn-danger common_business" id="{{business.business_code}}" data-type="{{business.business_code}}" data-extra="{{business.business_is_extra}}">{{business.business_name}}</button> {% endfor %} </div> </div> </div> </div> <div class="layui-collapse"> <div class="layui-colla-item"> <h3 class="layui-colla-title">日志</h3> <div class="layui-colla-content layui-show"><textarea placeholder="" id="log" class="layui-textarea" name="desc"></textarea></div> </div> <div class="layui-colla-item"> <h3 class="layui-colla-title">附加信息</h3> <div class="layui-colla-content layui-show" id="extra_info"> </div> </div> </div> <table class="layui-hide" id="table_message" lay-filter="user"></table> <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script> <script> layui.use('table', function(){ var table = layui.table; //方法級(jí)渲染 table.render({ elem: '#table_message' ,url: '/sms/message' ,method:'post' ,where: { phone: '', env_tools:parent.window.env_tools } ,cellMinWidth: 100 ,cols: [[ {checkbox: true, fixed: true} ,{field:'id', title: 'ID', sort: true,width:120, fixed: true} ,{field:'phone', title: '手機(jī)號(hào)',width:120} ,{field:'content', title: '短信內(nèi)容', sort: true} ,{field:'create_time', title: '發(fā)送時(shí)間',width:160} ]] ,id: 'testReload' ,page: true ,height: 500 }); var $ = layui.$, active = { reload: function(){ var demoReload = $('#phone'); $('.env_message').html('當(dāng)前操作環(huán)境:'+ parent.window.env_tools); //執(zhí)行重載 table.reload('testReload', { page: { curr: 1 //重新從第 1 頁(yè)開始 } ,where: { phone: demoReload.val(), env_tools:parent.window.env_tools } }); } }; $('.weadmin-block #query_sms').on('click', function(){ var type = $(this).data('type'); active[type] ? active[type].call(this) : ''; }); }); </script> {% endblock %}
(2)后臺(tái)代碼如下:
@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)頁(yè)面功能如下:
上述就是小編為大家分享的layui數(shù)據(jù)表格重載實(shí)現(xiàn)往后臺(tái)傳參了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
網(wǎng)頁(yè)題目:layui數(shù)據(jù)表格重載實(shí)現(xiàn)往后臺(tái)傳參-創(chuàng)新互聯(lián)
路徑分享:http://jinyejixie.com/article0/dsipio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營(yíng)銷、網(wǎng)站導(dǎo)航、網(wǎng)站策劃、定制網(wǎng)站、網(wǎng)站制作、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容