具有固定列的子行(显示额外/详细信息)

时间:2017-12-26 09:15:33

标签: javascript jquery datatables

1 个答案:

答案 0 :(得分:1)

我已在datatables论坛中发布了这个问题,并回答了这个问题。

https://datatables.net/forums/discussion/46536/child-rows-show-extra-detailed-information-with-fixed-columns?new=1

https://datatables.net/download/compatibility

我已经像这段代码一样解决了这个问题。

var dataSet = [];  // like json
var columnDefs = [];  // init data in the columns

var table = $('#example').DataTable( {
    data: dataSet,
    columns: columnDefs,
    scrollX: true,
});

// datatable fixed columns
var fixedColumns = new $.fn.dataTable.FixedColumns(table, {
    leftColumns: 0,
    rightColumns: 1
});
  

event.open详情控件

// unset fixed right column after epening additional details
fixedColumns.s.rightColumns = 0;
fixedColumns.s.iRightColumns = 0;
table.fixedColumns().update();

// hide fixed right column after epening additional details
$('.DTFC_RightWrapper').hide();
  

event.close详情控件

// set fixed right column after closing additional details
fixedColumns.s.rightColumns = 1;
fixedColumns.s.iRightColumns = 1;
table.fixedColumns().update();

// show fixed right column after closing additional details
$('.DTFC_RightWrapper').show();

链接jsfiddle