css - 合并 Bootstrap 表中的单元格

标签 css twitter-bootstrap-3 bootstrap-table

我在合并 Bootstrap Table 中的单元格时遇到问题 我找到了一个例子here .

但我不希望通过单击按钮来执行合并,而是希望自动合并。

这是我的代码:

<table id='ViewTable'
       data-toggle='table'
       data-url='func/json.php?id=1'
       data-class='table table-hover table-condensed'
       data-striped='true'
       data-show-header='false'>
    <thead>
    <tr>
        <th data-field='picture'></th>
        <th data-field='description'></th>
        <th data-field='value'></th>
    </tr>
    </thead>
    </table>

    <script>
    $(document).ready(function() {
        $('#ViewTable').bootstrapTable('mergeCells', {
                index: 0,
                field: 'picture',
                rowspan: 12
        });
    });
    </script>

有什么建议吗?

最佳答案

您可以使用 post-body.bs.table 事件来执行您想要的操作:

var $table = $('#ViewTable');

$(function () {
    $table.on('post-body.bs.table', function () {
        $table.bootstrapTable('mergeCells', {
            index: 0,
            field: 'picture',
            rowspan: 12
        });
    });
});

这是一个jsFiddle示例。

关于css - 合并 Bootstrap 表中的单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29864914/

相关文章:

css - Bootstrap - 我的导航栏不可扩展

javascript - 带有 Knockout JS 的文智信 Bootstrap-table

javascript - 基于另一列填充 BootstrapTable x-可编辑选择框

html - overflow hidden 时在 Webkit/mozilla 中滚动

html - 导航栏不会跟随用户

CSS 创建水平导航栏 - `li` s 与 `div` s

javascript - 在 Google Chrome 中加载图像的问题

html - Bootstrap : align form labels in different rows

css - 如何在导航栏折叠处于事件状态时禁用正文滚动

pug - 将超链接添加到由 bootstrap-table 生成的列中的文本