【问题标题】:Bootstrap Table Export Data issue引导表导出数据问题
【发布时间】:2016-02-14 03:35:43
【问题描述】:

我有一个使用 Jinja2 模板用 Python Flask 编写的 Web 应用程序。我正在尝试添加一个引导表以从表中导出数据。因此,我将 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.bokeh.org/bokeh/release/bokeh-0.9.2.min.css" type="text/css" />
<script type="text/javascript" src="http://cdn.bokeh**strong text**.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()
        });
    });
})

它创建了我的表,但导出数据不起作用。你能帮我吗?

【问题讨论】:

    标签: javascript python html twitter-bootstrap jinja2


    【解决方案1】:

    这可能意味着您bootstrap.table.min.css 的位置有问题。 如果你只有这个错误,请检查你有'bootstrap.min.css'的文件夹也有'bootstrap.table.min.css'。 如果不存在,请尝试从以下位置下载:http://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/bootstrap-table.min.css P.S:在您的代码中,您似乎有 bootstrap.table.min.css,不是 bootstrap-table.min.css。 (有一个点而不是'-')

    【讨论】:

    • 错误消失了,因为我修正了错字。但是,导出数据按钮不起作用。
    • 嗯,我可以看到您在那里有一张桌子,但 ID 为“pageTables”。我无法运行您的代码,但可能是选择器有问题,可能是 $table = $('#pageTables') ?
    • 我使用这个链接来创建它。并且
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多