123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>HTML table Export</title>
- <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
- <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.bundle.min.js"></script>
- <script src="https://unpkg.com/bootstrap-table@1.18.3/dist/bootstrap-table.min.js"></script>
- <script src="https://unpkg.com/bootstrap-table@1.18.3/dist/extensions/export/bootstrap-table-export.js"></script>
- <script src="https://unpkg.com/bootstrap-table@1.18.3/dist/extensions/toolbar/bootstrap-table-toolbar.js"></script>
- <script type="text/javascript" src="../tableExport.js"></script>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
- <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
- <link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.18.3/dist/bootstrap-table.min.css">
- <script type="text/javaScript">
- function detailFormatter(index, row) {
- var html = [];
- $.each(row, function (key, value) {
- html.push('<p><b>' + key + ':</b> ' + value + '</p>');
- });
- return html.join('');
- }
- function DoOnCellHtmlData(cell, row, col, data) {
- var result = "";
- if (typeof data != 'undefined' && data != "") {
- var html = $.parseHTML(data);
- $.each( html, function() {
- if ( typeof $(this).html() === 'undefined' )
- result += $(this).text();
- else if ( typeof $(this).attr('class') === 'undefined' || $(this).hasClass('th-inner') === true )
- result += $(this).html();
- });
- }
- return result;
- }
- $(function () {
- $('#toolbar').find('select').change(function () {
- $('#table').bootstrapTable('refreshOptions', {
- exportDataType: $(this).val()
- });
- });
- })
- $(document).ready(function()
- {
- $('#table').bootstrapTable('refreshOptions', {
- exportOptions: {ignoreColumn: [0,1], // or as string array: ['0','checkbox']
- onCellHtmlData: DoOnCellHtmlData}
- });
- });
- </script>
- </head>
- <body>
- <div class="container">
- <h1 align="center">Data</h1><br>
- <div id="toolbar">
- <select class="form-control">
- <option value="">Export Basic</option>
- <option value="all">Export All</option>
- <option value="selected">Export Selected</option>
- </select>
- </div>
- <table id="table"
- data-toggle="table"
- data-height="600"
- data-show-toggle="true"
- data-show-columns="true"
- data-show-export="true"
- data-click-to-select="true"
- data-toolbar="#toolbar"
- data-pagination="true"
- data-search="true"
- data-detail-view="true"
- data-detail-formatter="detailFormatter"
- data-filter-control="true"
- data-url="tableExport.json">
- <thead>
- <tr>
- <th data-field="checkbox" data-checkbox="true" > </th>
- <th data-field="Rank" data-sortable="true" data-filter-control="select" data-visible="true" >Rank </th>
- <th data-field="Flag" data-sortable="true" data-filter-control="input" data-visible="false" >Flag </th>
- <th data-field="Country" data-sortable="true" data-filter-control="select" data-visible="true" >Country </th>
- <th data-field="Population" data-sortable="true" data-filter-control="select" data-visible="false" >Population </th>
- <th data-field="Date" data-sortable="true" data-filter-control="select" data-visible="true" >Date </th>
- <th data-field="p_of_world" data-sortable="true" data-filter-control="select" data-visible="false" >% of world </th>
- <th data-field="Language" data-sortable="true" data-filter-control="select" data-visible="true" >Language </th>
- </tr>
- </thead>
- </table>
- </div>
- </body>
- </html>
|