代码之家  ›  专栏  ›  技术社区  ›  Bolek Lolek

具有动态高度的数据表固定列

  •  0
  • Bolek Lolek  · 技术社区  · 6 年前

    enter image description here

    http://jsfiddle.net/rn68jqth/20/

    2 回复  |  直到 6 年前
        1
  •  2
  •   Chanckjh    6 年前

    隐藏后需要重新绘制表。 http://jsfiddle.net/rn68jqth/42/

    $(function() {
    var table = $('#example').DataTable(
            {
              scrollY: "300px",
              scrollX: true,
              scrollCollapse: true,
              paging: false,
              ordering: false,
              bInfo: false,
              searching: false,
              fixedColumns:   {
                leftColumns: 1,
                heightMatch: 'auto'
              },
            });
    
      $('tr').on('click', function() {
      let index =  $(this).data('id');
        $('.tr_'+index).hide(function()
        {
            table.draw();
        });
      });
    
    
    });
    
        2
  •  1
  •   Abhishek Sharma    6 年前

    http://jsfiddle.net/rn68jqth/67/

    $(function() {
    var table = $('#example').DataTable(
            {
              scrollY: "300px",
              scrollX: true,
              scrollCollapse: true,
              paging: false,
              ordering: false,
              bInfo: false,
              searching: false,
              fixedColumns:   {
                leftColumns: 1,
                heightMatch: 'auto'
              },
            });
    
      $('tr').on('click', function() {
      var index =  $(this).data('id');
        //$('.tr_'+index).hide('fast');
        $('.tr_'+index).attr("style","display:none;");
        $('#example').DataTable().destroy();
        $('#example').DataTable({
        scrollY: "300px",
              scrollX: true,
              scrollCollapse: true,
              paging: false,
              ordering: false,
              bInfo: false,
              searching: false,
              fixedColumns:   {
                leftColumns: 1,
                heightMatch: 'auto'
              },
        });
      });
    });