一個功能齊全且使用者體驗良好的表格,查詢功能都是不可少的,因為表格的資料量有時可能相當龐大,這時候如果需要查找一個特定的數據,那將是十分龐大的工作量。下面我們就來為大家介紹如何使用bootstrap table外掛程式來實作查詢功能。
推薦教學:Bootstrap影片教學
#實作查詢想法:
1.定義一個局左的Toolbar包含新建、儲存和新建的按鈕
#2.定義一個局右的QueryForm 包含查詢條件和查詢清除按鈕
#3.定義一個Table
實作效果如下:
#程式碼如下
<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>
查詢函數實作
實現想法:取得查詢區塊中所有的對象,動態存放在查詢返回的參數中
需要注意:
當查詢沒有值的之後,不能放入查詢參數中,否則會把資料當做空來查詢,導致無法查詢到資料
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 会自动执行重新查询 }
重設函數的實作
實作想法:循環取得query-form的控件,並把其值置空
function resetSearch() { $('#query-form').find('[name]').each(function () { $(this).val(''); }); }
以上是Bootstrap Table 查詢實現的詳細內容。更多資訊請關注PHP中文網其他相關文章!

將Bootstrap集成到React項目中的步驟包括:1.安裝Bootstrap包,2.導入CSS文件,3.使用Bootstrap類名樣式化元素,4.使用React-Bootstrap或reactstrap庫來使用Bootstrap的JavaScript組件。這種集成利用React的組件化和Bootstrap的樣式系統,實現高效的UI開發。

bootstrapisapowerfulflameworkthatsimplifiesCreatingingResponsive,移動 - firstwebsites.itoffers.itoffers:1)AgridSystemforadaptableBableLayouts,2)2)pre-styledlementslikeButtonslikeButtonSandForms和3)JavaScriptCompriptcomponcomponentsSuchcaroSelSuselforEnhanceSuch forenhanceTinteractivity。

Bootstrap是一個由Twitter開發的前端框架,集成了HTML、CSS和JavaScript,幫助開發者快速構建響應式網站。其核心功能包括:柵格系統與佈局:基於12列的設計,使用flexbox佈局,支持不同設備尺寸的響應式頁面。組件與樣式:提供豐富的組件庫,如按鈕、模態框等,通過添加類名即可實現美觀效果。工作原理:依賴CSS和JavaScript,CSS使用LESS或SASS預處理器,JavaScript依賴jQuery,實現交互和動態效果。通過這些功能,Bootstrap大大提升了開發

BootstrapisafreeCSSframeworkthatsimplifieswebdevelopmentbyprovidingpre-styledcomponentsandJavaScriptplugins.It'sidealforcreatingresponsive,mobile-firstwebsites,offeringaflexiblegridsystemforlayoutsandasupportivecommunityforlearningandcustomization.

Bootstrapisafree,open-sourceCSSframeworkthathelpscreateresponsive,mobile-firstwebsites.1)Itoffersagridsystemforlayoutflexibility,2)includespre-styledcomponentsforquickdesign,and3)ishighlycustomizabletoavoidgenericlooks,butrequiresunderstandingCSStoop

Bootstrap適合快速搭建和小型項目,而React適合複雜的、交互性強的應用。 1)Bootstrap提供預定義的CSS和JavaScript組件,簡化響應式界面開發。 2)React通過組件化開發和虛擬DOM,提升性能和交互性。

Bootstrap的主要用途是幫助開發者快速構建響應式、移動優先的網站。其核心功能包括:1.響應式設計,通過網格系統實現不同設備的佈局調整;2.預定義組件,如導航欄和模態框,確保美觀和跨瀏覽器兼容性;3.支持自定義和擴展,使用Sass變量和mixins調整樣式。

Bootstrap優於TailwindCSS、Foundation和Bulma,因為它易用且快速開發響應式網站。 1.Bootstrap提供豐富的預定義樣式和組件庫。 2.其CSS和JavaScript庫支持響應式設計和交互功能。 3.適合快速開發,但自定義樣式可能較複雜。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

SublimeText3 Linux新版
SublimeText3 Linux最新版

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能