阻止 FooTable 在<td>转换单元格时从标签中删除 html



我正在使用FooTable(http://fooplugins.github.io/FooTable/docs/getting-started.html)从我的静态html表创建一些动态表。

表的单元格或标记中有html,用于格式化单元格中的值。例如,我在一个单元格中使用自举标签组件。

我遇到的问题是,当footable运行时,它会转换所有的html格式,并且似乎会从单元格中剥离所有这些html标记,而我只剩下文本。

例如,我可能在一个单元格中有:

<td><span class="label label-default">Default</span></td>

转换为:

<td>Default</td>

我的问题是,有没有办法阻止这种情况的发生?我在谷歌上搜索了一下,并在可步行的文档上搜索了一遍,但我运气不好。

似乎没有多少人遇到过这个问题。但肯定有人知道这是否可能。

您可以尝试将列标识为HTML,在具有HTML的列中使用data-type="html"

示例:

            <table id="testTable" class="table" data-paging="true">
            <thead>
                <tr>
                    <th style="width: 45%">Origin</th>
                    <th data-breakpoints="sm xs" style="width: 45%">Destination</th>
                    <th style="width: 5%" data-type="html">&nbsp;</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>O1</td>
                    <td>D1</td>
                    <td><span class="glyphicon glyphicon-remove"></span>&nbsp;<span class="glyphicon glyphicon-pencil"></span></td>
                </tr>
                <tr>
                    <td>O2</td>
                    <td>D2</td>
                    <td><span class="glyphicon glyphicon-remove"></span>&nbsp;<span class="glyphicon glyphicon-pencil"></span></td>
                </tr>
                <tr>
                    <td>O3</td>
                    <td>D3</td>
                    <td><span class="glyphicon glyphicon-remove"></span>&nbsp;<span class="glyphicon glyphicon-pencil"></span></td>
                </tr>
            </tbody>
        </table>

Javascript:

$("#testTable").footable();

您尝试过创建自己的格式化程序吗?

jQuery(function($){
    $('.table').footable({
        "columns": [{
            "formatter": function(value){
                return value;
            }
        }]
    });
});

它看起来有点多余,但它确实有一个默认的"类型"格式化程序,所以也许只需直接将值传递回来,而不需要任何额外的未知魔法就可以解决这个问题。

最新更新