0
我有一個使用Jinja2模板在Python Flask中編寫的Web應用程序。我試圖添加一個Bootstrap表來從表中導出數據。因此,我下載並將CSS和Javascript文件複製到適當的文件夾中,並如下所示引用它們。引導程序表導出數據問題
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-table.min.css') }}">
<script type="text/javascript" src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='js/jquery.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='js/bootstrap-table.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='js/bootstrap-table-export.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='js/tableexport.js') }}"></script>
<script>$("div.navbar-fixed-top").autoHidingNavbar();</script>
<link href="http://getbootstrap.com/examples/justified-nav/justified-nav.css" rel="stylesheet">
<link rel="stylesheet" href="http://cdn.pydata.org/bokeh/release/bokeh-0.9.2.min.css" type="text/css" />
<script type="text/javascript" src="http://cdn.pydata.org/bokeh/release/bokeh-0.9.2.min.js"></script>
要創建表,我有這部分代碼:
<table class="table table-bordered table-hover" id="pageTables" data-toggle="table" data-show-columns="true" data-search="true" data-show-refresh="true" data-show-toggle="true" data-show-export="true" data-pagination="true" data-click-to-select="true" data-toolbar="#toolbar">
<thead>
<tr>
<th data-field="E">E</th>
<th data-field="bthrs">Base </th>
<th data-field="mag">Mag</th>
<th data-field="ht">Ho (secs)</th>
<th data-field="dt">De(secs)</th>
</tr>
</thead>
....
<script>
var $table = $('#table');
$(function() {
$('#toolbar').find('select').change(function() {
$table.bootstrapTable('refreshOptions', {
exportDataType: $(this).val()
});
});
})
它創建我的表,但出口數據不起作用。你能幫我解決嗎?
錯誤消失了,因爲我修復了錯字。但是,導出數據按鈕不起作用。 –
嗯,我可以看到你有一張桌子,但ID爲「pageTables」。我無法運行你的代碼,但也許有選擇器有問題,也許$ table = $('#pageTables')? – ATud
我用這個鏈接來創建它。並從那裏複製