搜尋
首頁web前端Bootstrap教程Bootstrap Table 查詢實現

Bootstrap Table 查詢實現

Aug 20, 2019 pm 03:33 PM

Bootstrap Table 查詢實現

一個功能齊全且使用者體驗良好的表格,查詢功能都是不可少的,因為表格的資料量有時可能相當龐大,這時候如果需要查找一個特定的數據,那將是十分龐大的工作量。下面我們就來為大家介紹如何使用bootstrap table外掛程式來實作查詢功能。

推薦教學:Bootstrap影片教學

#實作查詢想法: 

1.定義一個局左的Toolbar包含新建、儲存和新建的按鈕 

#2.定義一個局右的QueryForm 包含查詢條件和查詢清除按鈕 

#3.定義一個Table

實作效果如下: 

Bootstrap 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=&#39;<@spring.message "fnd.lookup_type"/>&#39; 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=&#39;<@spring.message "fnd.description"/>&#39; 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 = {};
    $(&#39;#query-form&#39;).find(&#39;[name]&#39;).each(function () {
        var value = $(this).val();
        if (value != &#39;&#39;) {
            param[$(this).attr(&#39;name&#39;)] = value;
        }
    });

    param[&#39;pageSize&#39;] = params.limit;   //页面大小
    param[&#39;pageNumber&#39;] = params.offset;   //页码

    return param;
}

function customSearch(text) {
    $table.bootstrapTable(&#39;refresh&#39;);//刷新Table,Bootstrap Table 会自动执行重新查询
}

重設函數的實作 

實作想法:循環取得query-form的控件,並把其值置空

function resetSearch() {
    $(&#39;#query-form&#39;).find(&#39;[name]&#39;).each(function () {
        $(this).val(&#39;&#39;);
    });
}

以上是Bootstrap Table 查詢實現的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
將引導程序集成到React:實用指南將引導程序集成到React:實用指南Apr 25, 2025 am 12:04 AM

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

Bootstrap是用什麼?一個實用的解釋Bootstrap是用什麼?一個實用的解釋Apr 24, 2025 am 12:16 AM

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

引導程序:從佈局到組件引導程序:從佈局到組件Apr 23, 2025 am 12:06 AM

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

什麼是bootstrap?初學者的介紹什麼是bootstrap?初學者的介紹Apr 22, 2025 am 12:07 AM

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

Bootstrap Demystified:一個簡單的解釋Bootstrap Demystified:一個簡單的解釋Apr 21, 2025 am 12:13 AM

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

引導與反應:選擇正確的方法引導與反應:選擇正確的方法Apr 20, 2025 am 12:09 AM

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

Bootstrap的目的:建立一致且有吸引力的網站Bootstrap的目的:建立一致且有吸引力的網站Apr 19, 2025 am 12:07 AM

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

Bootstrap與其他框架:比較概述Bootstrap與其他框架:比較概述Apr 18, 2025 am 12:06 AM

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

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

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

熱工具

SublimeText3 Mac版

SublimeText3 Mac版

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

mPDF

mPDF

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

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

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

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

EditPlus 中文破解版

EditPlus 中文破解版

體積小,語法高亮,不支援程式碼提示功能