具有固定标题的可调整大小的列表 [英] Resizable columns tables with fixed header

查看:72
本文介绍了具有固定标题的可调整大小的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建具有可调整大小的列和固定标题的表. 但是,当我尝试拖动标题列时,表列会更改其大小,但是会产生一些间隙.

I'm trying to create a table with resizable columns and fixed header. But when I'm trying to drag the header column, table columns change their size, but some gap is created.

例如:

拖动后我得到的是:

What I get after dragging:

我的样品:

<script>
$(document).ready(function(){

    $('#tableHeader').colResizable({
        liveDrag: true,
        onDrag: resFun
    });


    function resFun() {
        var c1 = $('#c1').width();
        var c2 = $('#c2').width();
        var c3 = $('#c3').width();

        $('.c1').width(c1);
        $('.c2').width(c2);
        $('.c3').width(c3);

    };

    resFun();
});
</script>

<div style="padding-right: 17px; height: 39px;">
    <table class="table table-bordered" id="tableHeader" style="width: 100%; height: 39px;">
        <tr>
            <th id="c1">first</th>
            <th id="c2">second</th>
            <th id="c3">third</th>
        </tr>
    </table>
</div>
<div style="overflow: auto; height: 200px;">
    <table class="table table-bordered" id="table">
        <tr>
            <td class="c1">col 1</td>
            <td class="c2">col 2</td>
            <td class="c3">col 3</td>
        </tr>
        <tr>
            <td class="c1">col 1</td>
            <td class="c2">col 2</td>
            <td class="c3">col 3</td>
        </tr>
        <tr>
            <td class="c1">col 1</td>
            <td class="c2">col 2</td>
            <td class="c3">col 3</td>
        </tr>
        <tr>
            <td class="c1">col 1</td>
            <td class="c2">col 2</td>
            <td class="c3">col 3</td>
        </tr>
        <tr>
            <td class="c1">col 1</td>
            <td class="c2">col 2</td>
            <td class="c3">col 3</td>
        </tr>
        <tr>
            <td class="c1">col 1</td>
            <td class="c2">col 2</td>
            <td class="c3">col 3</td>
        </tr>
        <tr>
            <td class="c1">col 1</td>
            <td class="c2">col 2</td>
            <td class="c3">col 3</td>
        </tr>
        <tr>
            <td class="c1">col 1</td>
            <td class="c2">col 2</td>
            <td class="c3">col 3</td>
        </tr>
    </table>
</div>

推荐答案

问题是第二个表的单元格具有填充集,而标头的单元格没有填充..应该没事

The problem is that the cells of the second table have a padding set and the cells of the header doesn't.. add padding to the header as well and should be ok

这篇关于具有固定标题的可调整大小的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆