這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)?lái)有關(guān)如何實(shí)現(xiàn)Bootstrap Table 查詢,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
一個(gè)功能齊全且用戶體驗(yàn)良好的表格,查詢功能都是并不可少的,因?yàn)楸砀竦臄?shù)據(jù)量有時(shí)可能相當(dāng)龐大,這時(shí)候如果需要查找一個(gè)特定的數(shù)據(jù),那將是十分龐大的工作量。下面我們就為大家介紹一下如何使用bootstrap table插件來(lái)實(shí)現(xiàn)查詢功能。
實(shí)現(xiàn)查詢思路:
1.定義一個(gè)局左的Toolbar包含 新建、保存和新建的按鈕
2.定義一個(gè)局右的QueryForm 包含查詢條件 和 查詢清除按鈕
3.定義一個(gè)Table
實(shí)現(xiàn)效果如下:
代碼如下
<div class="container-fluid"> <div> <div id="toolbar-btn" class="btn-group pull-left" style="padding-bottom:10px;"> <button id="btn_add" οnclick="createFunction()" type="button" class="btn btn-primary btn-space"> <span class="fa fa-plus-square" aria-hidden="true" class="btn-icon-space"></span> <@spring.message "fnd.new"/> </button> <button id="btn_save" οnclick="saveFunction()" type="button" class="btn btn-success btn-space"> <span class="fa fa-save" aria-hidden="true" class="btn-icon-space"></span> <@spring.message "fnd.save"/> </button> <button id="btn_delete" οnclick="deleteFunction()" type="button" class="btn btn-danger btn-space"> <span class="fa fa-trash-o" aria-hidden="true" class="btn-icon-space"></span> <@spring.message "fnd.delete"/> </button> </div> <div class="pull-right" id="query-form" style="padding-bottom:10px;"> <input name="lookupType" placeholder='<@spring.message "fnd.lookup_type"/>' type="text" style="float:left;width:150px;margin-right:5px;" v-model="lookupType" class="form-control"> <div style="float:left;margin-right:5px;"> <input name="description" placeholder='<@spring.message "fnd.description"/>' type="text" style="float:left;width:150px;margin-right:5px;" v-model="description" class="form-control"> </div> <div class="btn-group"> <button id="btn_search" οnclick="customSearch()" type="button" class="btn btn-primary btn-space"> <span class="fa fa-search" aria-hidden="true" class="btn-icon-space"></span> <@spring.message "fnd.query"/> </button> <button id="btn_reset" οnclick="resetSearch()" type="button" class="btn btn-default btn-space"> <span class="fa fa-eraser" aria-hidden="true" class="btn-icon-space"></span> <@spring.message "fnd.reset"/> </button> </div> </div> </div> <table id="table" class="table table-condensed table-striped"></table> </div>
查詢函數(shù)實(shí)現(xiàn)
實(shí)現(xiàn)思路:獲取查詢塊中所有的對(duì)象,動(dòng)態(tài)存放在查詢返回的參數(shù)中
需要注意:
當(dāng)查詢沒(méi)有值的之后,不能放入到查詢參數(shù)中,否則會(huì)把數(shù)據(jù)當(dāng)做空來(lái)查詢,從而導(dǎo)致無(wú)法查詢到數(shù)據(jù)
function queryParams(params) { var param = {}; $('#query-form').find('[name]').each(function () { var value = $(this).val(); if (value != '') { param[$(this).attr('name')] = value; } }); param['pageSize'] = params.limit; //頁(yè)面大小 param['pageNumber'] = params.offset; //頁(yè)碼 return param; } function customSearch(text) { $table.bootstrapTable('refresh');//刷新Table,Bootstrap Table 會(huì)自動(dòng)執(zhí)行重新查詢 }
重置函數(shù)的實(shí)現(xiàn)
實(shí)現(xiàn)思路:循環(huán)獲取query-form的控件,并把其值置空
function resetSearch() { $('#query-form').find('[name]').each(function () { $(this).val(''); }); }
上述就是小編為大家分享的如何實(shí)現(xiàn)Bootstrap Table 查詢了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)網(wǎng)站制作公司行業(yè)資訊頻道。
本文標(biāo)題:如何實(shí)現(xiàn)BootstrapTable查詢-創(chuàng)新互聯(lián)
分享地址:http://jinyejixie.com/article14/dssgde.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開(kāi)發(fā)、微信小程序、企業(yè)網(wǎng)站制作、ChatGPT、Google、定制網(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)容