web表格导出插件-bootstrap-table-export
web表格导出插件-bootstrap-table-export
<html> <link href="https://unpkg.com/bootstrap-table@1.18.0/dist/bootstrap-table.min.css" rel="stylesheet"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="https://unpkg.com/tableexport.jquery.plugin/tableExport.min.js"></script> <script src="https://unpkg.com/bootstrap-table@1.18.0/dist/bootstrap-table.min.js"></script> <script src="https://unpkg.com/bootstrap-table@1.18.0/dist/bootstrap-table-locale-all.min.js"></script> <script src="https://unpkg.com/bootstrap-table@1.18.0/dist/extensions/export/bootstrap-table-export.min.js"></script> <div id="toolbar"> <button id="remove" class="btn btn-danger" disabled> <i class="fa fa-trash"></i> Delete </button> </div> <table id="table" data-toggle="table" data-toggle="table" data-show-columns="true" data-show-columns-toggle-all="true" data-pagination="true" data-show-export="true" data-locale="zh-CN" data-search="true"> <thead> <tr> <th data-checkbox="true"></th> <th data-sortable="true" data-field="id">Item ID</th> <th data-field="name">Item Name</th> <th data-field="price">Item Price</th> </tr> </thead> <tbody> <tr> <th data-checkbox="true"></th> <td>1</td> <td>Item 1</td> <td>$1</td> </tr> <tr> <th data-checkbox="true"></th> <td>2</td> <td>Item 2</td> <td>$2</td> </tr> </tbody> </table> <script type="text/javascript"> var $table = $('#table') var $remove = $('#remove') var selections = [] function getIdSelections() { return $.map($table.bootstrapTable('getSelections'), function (row) { return row.id }) } $table.on('check.bs.table uncheck.bs.table ' + 'check-all.bs.table uncheck-all.bs.table', function () { $remove.prop('disabled', !$table.bootstrapTable('getSelections').length) // save your data, here just save the current page selections = getIdSelections() // push or splice the selections if you want to save all data selections }) $remove.click(function () { var ids = getIdSelections() alert(ids) $table.bootstrapTable('remove', { field: 'id', values: ids }) $remove.prop('disabled', true) }) </script> </html>
效果
选择字段展示和导出
合集:
HTML
分类:
编程相关 / HTML
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了