這期內容當中小編將會給大家?guī)碛嘘P如何實現(xiàn)Bootstrap Table 查詢,文章內容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
襄城網站建設公司創(chuàng)新互聯(lián),襄城網站設計制作,有大型網站制作公司豐富經驗。已為襄城千余家提供企業(yè)網站建設服務。企業(yè)網站搭建\成都外貿網站建設公司要多少錢,請找那個售后服務好的襄城做網站的公司定做!一個功能齊全且用戶體驗良好的表格,查詢功能都是并不可少的,因為表格的數(shù)據量有時可能相當龐大,這時候如果需要查找一個特定的數(shù)據,那將是十分龐大的工作量。下面我們就為大家介紹一下如何使用bootstrap table插件來實現(xiàn)查詢功能。
實現(xiàn)查詢思路:
1.定義一個局左的Toolbar包含 新建、保存和新建的按鈕
2.定義一個局右的QueryForm 包含查詢條件 和 查詢清除按鈕
3.定義一個Table
實現(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ù)實現(xiàn)
實現(xiàn)思路:獲取查詢塊中所有的對象,動態(tài)存放在查詢返回的參數(shù)中
需要注意:
當查詢沒有值的之后,不能放入到查詢參數(shù)中,否則會把數(shù)據當做空來查詢,從而導致無法查詢到數(shù)據
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; //頁面大小 param['pageNumber'] = params.offset; //頁碼 return param; } function customSearch(text) { $table.bootstrapTable('refresh');//刷新Table,Bootstrap Table 會自動執(zhí)行重新查詢 }
重置函數(shù)的實現(xiàn)
實現(xiàn)思路:循環(huán)獲取query-form的控件,并把其值置空
function resetSearch() { $('#query-form').find('[name]').each(function () { $(this).val(''); }); }
上述就是小編為大家分享的如何實現(xiàn)Bootstrap Table 查詢了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注創(chuàng)新互聯(lián)網站制作公司行業(yè)資訊頻道。
本文標題:如何實現(xiàn)BootstrapTable查詢-創(chuàng)新互聯(lián)
分享地址:http://bm7419.com/article14/dssgde.html
成都網站建設公司_創(chuàng)新互聯(lián),為您提供App開發(fā)、微信小程序、企業(yè)網站制作、ChatGPT、Google、定制網站
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)