bootstrap-table如何實(shí)現(xiàn)表格導(dǎo)出-創(chuàng)新互聯(lián)

這篇文章主要為大家展示了“bootstrap-table如何實(shí)現(xiàn)表格導(dǎo)出”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“bootstrap-table如何實(shí)現(xiàn)表格導(dǎo)出”這篇文章吧。

目前成都創(chuàng)新互聯(lián)已為上1000+的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、成都網(wǎng)站托管、企業(yè)網(wǎng)站設(shè)計(jì)、寧國(guó)網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。

在bootstrap-table官網(wǎng)-》拓展模塊中有導(dǎo)出模塊的詳細(xì)介紹。網(wǎng)址:http://bootstrap-table.wenzhixin.net.cn/zh-cn/extensions/

點(diǎn)擊home按鈕進(jìn)入github官方文檔,會(huì)看到導(dǎo)出使用的插件是bootstrap-table-export.js  ,而這個(gè)插件中使用的是tableExport.jquery.plugin插件。后者是一個(gè)獨(dú)立的表格導(dǎo)出插件。而前者是經(jīng)過(guò)bootstrap官方將后者與bootstrap表格進(jìn)行了完美的整合之后的插件。所以我們只需要使用前者即可。

文檔參數(shù)說(shuō)明:

Table Export

Use Plugin: tableExport.jquery.plugin

Usage

<script src="extensions/export/bootstrap-table-export.js"></script>

Options

showExport        //是否顯示到處按鈕

    type: Boolean

    description: set true to show export button.

    default: false

    exportDataType   //導(dǎo)出表格方式(默認(rèn)basic:只導(dǎo)出當(dāng)前頁(yè)的表格數(shù)據(jù);all:導(dǎo)出所有數(shù)據(jù);selected:導(dǎo)出選中的數(shù)據(jù))

      type: String

      description: export data type, support: 'basic', 'all', 'selected'.

      default: basic

      exportTypes   //導(dǎo)出文件類型 ,支持多種類型文件導(dǎo)出

        type: Array

        description: export types, support types: 'json', 'xml', 'png', 'csv', 'txt', 'sql', 'doc', 'excel', 'xlsx', 'pdf'.

        default: ['json', 'xml', 'csv', 'txt', 'sql', 'excel']

        exportOptions  //導(dǎo)出的表格參數(shù)設(shè)置,這里參照tableExport.jquery.plugin插件中的參數(shù)進(jìn)行設(shè)置,點(diǎn)擊官網(wǎng)文檔中的option藍(lán)色字體就可跳轉(zhuǎn)到該插件的說(shuō)明文檔處,網(wǎng)址:https://github.com/hhurz/tableExport.jquery.plugin#options。

          type: Object

          description: export options of tableExport.jquery.plugin

          default: {}

          Icons     //導(dǎo)出按鈕圖標(biāo)設(shè)置

            export: 'glyphicon-export icon-share'

            下面直接貼代碼:

            //查詢    function refresh(){        $("#datatable").bootstrapTable('refresh',{url:'__MODULE__/Statistics/listData'});    }    //查詢條件    function queryParams(params){        params['project_id'] = $("select[name=project_id]").find("option:selected").val();        params['time_field'] = $("select[name=time_field]").find("option:selected").val();        params['start_time'] = $("input[name=start_time]").val();        params['end_time'] = $("input[name=end_time]").val();        params['user_name'] = $("input[name=user_name]").val();        params['telephone'] = $("input[name=telephone]").val();        params['room_confirm_number'] = $("input[name=room_confirm_number]").val();        params['lineson'] = $("select[name=lineson]").val();        params['invoice'] = $("select[name=invoice]").val();        return params;    }      function DoOnMsoNumberFormat(cell, row, col) {        var result = "";        if (row > 0 && col == 0)            result = "\\@";        return result;    }    var rowCount = 0;    $("#datatable").bootstrapTable({        height:"500",        url: '__MODULE__/Statistics/listData',  //表格數(shù)據(jù)請(qǐng)求地址        pagination:true,   //是否分頁(yè)        search: false,    //是否顯示查詢框        sortName: "id",    //排序相關(guān)        sortOrder: "desc",        queryParams:'queryParams',        method:"post",        sortable:true,        dataType:'json',        toolbar: "#exampleTableEventsToolbar",        icons: {refresh: "glyphicon-repeat", toggle: "glyphicon-list-alt", columns: "glyphicon-list"},        pageList:[10, 25, 50, 100],        clickToSelect:true,        exportDataType:'all',         onLoadSuccess:function(data){   //表格數(shù)據(jù)加載成功事件            rowCount = data.length-1;            $("#datatable").bootstrapTable('hideRow', {index:rowCount});            $("#datatable td").attr("data-tableexport-msonumberformat","\@");            $("#datatable tr").attr("data-tableexport-display","always");        },        onPageChange:function(number,size){  //表格翻頁(yè)事件            $("#datatable").bootstrapTable('hideRow', {index:rowCount});            $("#datatable td").attr("data-tableexport-msonumberformat","\@");            $("#datatable tr").attr("data-tableexport-display","always");         },        showExport: true,  //是否顯示導(dǎo)出按鈕        buttonsAlign:"right",  //按鈕位置        exportTypes:['excel'],  //導(dǎo)出文件類型        Icons:'glyphicon-export',        exportOptions:{            ignoreColumn: [0,1],  //忽略某一列的索引            fileName: '總臺(tái)帳報(bào)表',  //文件名稱設(shè)置            worksheetName: 'sheet1',  //表格工作區(qū)名稱            tableName: '總臺(tái)帳報(bào)表',            excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],            onMsoNumberFormat: DoOnMsoNumberFormat        },        columns: [            {                checkbox:true,                title: '選擇'            },{                title: '序號(hào)',                formatter: function (value, row, index) {                    $(".group_sum").html(row['group_sum']);                    $(".group_money_sum").html(row['group_money_sum']+"元");                    $(".confirm_sum").html(row['confirm_sum']);                    $(".confirm_money_sum").html(row['confirm_money_sum']+"元");                    $(".refund_sum").html(row['refund_sum']);                    $(".refund_money_sum").html(row['group_back_sum']+"元");                    $(".residue_money_sum").html(row['residue_sum']+"元");                    var a = index+1; return a+"<span style='display:none;'>"+row.id+"</span>"                }            },{                field: 'project_name',                align:"center",                title: '項(xiàng)目'            }, {                field: 'user_name',                align:"center",                title: '姓名'            }, {                field: 'telephone',                align:"center",                title: '電話'            },{                field: 'id_card_number',                align:"center",                rowAttributes:"rowAttributes",                title: '身份證號(hào)'            },{                field: 'telephone',                align:"center",                title: '手機(jī)號(hào)'            },{                field: 'pos_r_n',                align:"center",                title: 'POS機(jī)參考號(hào)'            },{                field: 'pos_c_n',                align:"center",                title: 'POS機(jī)終端號(hào)'            },{                field: 'merchant_code',                align:"center",                title: '商戶編碼'            },{                field: 'bank_card_number',                align:"center",                title: '銀行卡號(hào)'            },{                field: 'create_time',                align:"center",                title: '領(lǐng)取優(yōu)惠時(shí)間'            },{                field: 'group_purchase_number',                align:"center",                title: '優(yōu)惠編碼'             },{                field: 'group_purchase_expenses',                align:"center",                title: '會(huì)員費(fèi)用'            },{                field: 'back_pay_money',                align:"center",                title: '退款金額'            },{                field: 'refund_etime',                align:"center",                title: '退款時(shí)間'            },{                field: 'confirm_pay_money',                align:"center",                title: '認(rèn)購(gòu)金額'            },{                field: 'group_purchase_confirm_time',                align:"center",                title: '認(rèn)購(gòu)時(shí)間'            },{                field: 'room_confirm_number',                align:"center",                title: '認(rèn)購(gòu)房號(hào)'            },{                field: '',                align:"center",                title: '賬戶余額'            },{                field: 'invoice_status',                align:"center",                title: '發(fā)票狀態(tài)',                formatter: 'invoice_status_formatter',                events:'confirmEvents'            },{                field: 'lineson',                align:"center",                title: '數(shù)據(jù)來(lái)源',                formatter: 'lineson_status_formatter',                events:'confirmEvents'            }        ]    });

以上是“bootstrap-table如何實(shí)現(xiàn)表格導(dǎo)出”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

名稱欄目:bootstrap-table如何實(shí)現(xiàn)表格導(dǎo)出-創(chuàng)新互聯(lián)
轉(zhuǎn)載源于:http://muchs.cn/article26/ddcdjg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、建站公司外貿(mào)建站、面包屑導(dǎo)航、動(dòng)態(tài)網(wǎng)站軟件開(kāi)發(fā)

廣告

聲明:本網(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)

小程序開(kāi)發(fā)