使用细丝组tablesaw插件时未显示标签

Label not displayed while using filament group tablesaw plugin

本文关键字:显示 标签 插件 tablesaw      更新时间:2023-12-02

我一直在尝试使用细丝组的tablesaw插件(仅限堆栈版本)来渲染一个响应表。视图基本上是使用主干和下划线模板进行渲染的。但是,在减少视图端口的同时,标签不会显示出来。

https://github.com/filamentgroup/tablesaw

我的背部骨骼视图如下。该模型是从spec.json文件中读取的。

App.views.AnalyticsView = Backbone.View.extend({
    render: function () {
        this.$el.html(this.template());
        var $tableBody = this.$el.find('#table-body');
        //Creating analytics table rows from spec.json
        //Appending to table body in analytics page template
        _.each(this.collection.models, function(model) {
            var rowHtml = '<tr>';
            _.each(model.attributes, function(value) {
                rowHtml += '<td>' + value + '</td>';
            });
            rowHtml += '</tr>';
            $tableBody.append(rowHtml);            
        });
        return this;
    }
});

我的下划线模板如下-

<div class="row-fluid">
    <div class="span12">
        <p><%_ analytics.intro %></p>
    </div>
</div>
<div>
</div>
    <table class="tablesaw tablesaw-stack" data-tablesaw-mode="stack">
      <thead id="table-head">
         <th><%_ analytics.parameter %></th>
         <th><%_ analytics.title %></th>
         <th><%_ analytics.apisource %></th>
         <th><%_ analytics.description %></th>
      </thead>
      <tbody id="table-body"></tbody>
    </table>
</div>

表头使用underi18n进行国际化。我是一个新手,所以请随时告诉我是否有更好的方法来呈现这个观点。我的目标是获得一个完全响应的表,其数据将从spec.json文件中设置。

提前谢谢。

所以问题已经解决了。我不得不编辑tablesaw插件中的几行,特别是触发事件的地方。

早些时候是-this.$table.trigger( events.create, [ this, colstart ] );,它没有触发所需的事件。我把它改成了$( document ).trigger( events.create, [ this, colstart ] );,这样它就可以工作了。

我直接使用this.$el.find("#analytics-table").table();调用了该插件。此外,我还删除了与该插件相关的"增强表锯"事件。

感谢@ahmad的帮助