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

时间:2018-06-27 07:17:39

标签: javascript jquery css datatable datatables

一切正常,直到我单击<tr>(删除行)。表的高度已更改,但固定列始终相同。问题是删除行(固定列下的部分)后不能使用底部滚动条

enter image description here

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

2 个答案:

答案 0 :(得分:2)

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

implementation 'com.android.support:support-v4:28.+'

答案 1 :(得分:1)

您还可以销毁表并重新创建,而不是使用hide show display none。 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'
          },
    });
  });
});
相关问题