jquery - Bootstrap-table 动态改变表格高度

标签 jquery twitter-bootstrap-3 bootstrap-table

我在 1.6 版本中使用 Bootstrap-table 插件。 我想动态改变 table 高度 - 这可能吗?我不知道该怎么做...

<div class="main">
    <button id="resetView" class="btn btn-default">Reset View</button>

    <table id="table"
           data-toggle="table"
           data-url="/gh/get/response.json/wenzhixin/bootstrap-table/tree/master/docs/data/data1/"
           data-height="200">
        <thead>
        <tr>
            <th data-field="name">Name</th>
            <th data-field="stargazers_count">Stars</th>
            <th data-field="forks_count">Forks</th>
            <th data-field="description">Description</th>
        </tr>
        </thead>
    </table>

$(function () {
    setTimeout(function () {
        $('.main').width('80%'); // Change table width

        $('.main').height('100'); // it won't work
        $('#table').data('height', 100); // this also won't work
        $('#table').height('100'); // and of course this won't work..
    }, 1000);

    $('#resetView').click(function () {
        $('#table').bootstrapTable('resetView');
    });
});

工作 fiddle http://jsfiddle.net/e3nk137y/558/

最佳答案

终于成功了...

$('#table').bootstrapTable( 'resetView' , {height: 200} );

关于jquery - Bootstrap-table 动态改变表格高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28380957/

相关文章:

javascript - 用于 URL 的 Bootstrap 表格式化程序

javascript - 我无法使用 jquery 获取几个 div 内的 select html 的值

javascript - 在 javascript 中选择操作

html - 如何将两列并排放置

html - 在父 div 下打开 Bootstrap Accordion 内容

html - 如何使用 bootstrap 在表单中获得内联标签和标准标签的组合?

javascript - 如何将 JSON/Bootstrap-Table 中的日期转换为 DD/MM/YYYY

javascript - 链接到外部 .js 文件时,这不是安全风险吗?

javascript - 是否可以在 JS 或 jQuery 中更改 X 背景位置而不影响元素的 Y 背景位置?

javascript - Bootstrap 表条件显示/隐藏列