datatables row toggle和fixedColumns

时间:2017-09-02 22:02:59

标签: jquery datatables

我使用datatable-row-toggle-option功能(分组​​和折叠行)

DataTable Row Toggle Option

并且需要datatables.fixedColumns(第一列总是显示)

但新创建的行与类别make fixedColumns插件中的错误

此抛出错误

Uncaught TypeError: Cannot read property 'anCells' of undefined
at HTMLTableRowElement.<anonymous> (dataTables.fixedColumns.min.js:27)
at Function.each (jquery.min.js:130)
at init.each (jquery.min.js:49)
at m._fnClone (dataTables.fixedColumns.min.js:27)
at m._fnCloneLeft (dataTables.fixedColumns.min.js:23)
at m._fnDraw (dataTables.fixedColumns.min.js:22)
at HTMLTableElement.<anonymous> (dataTables.fixedColumns.min.js:13)
at HTMLTableElement.dispatch (jquery.min.js:1199)
at HTMLTableElement.y.handle (jquery.min.js:1153)
at Object.trigger (jquery.min.js:1188)

这是我的配置:

var table = $('#example').DataTable( {
                        ajax: {                     
                        "drawCallback": function ( settings ) {
                            var api = this.api();
                            var rows = api.rows( {page:'current'} ).nodes();
                            var last=null;

                            api.column(1, {page:'current'} ).data().each( function ( group, i ) {
                                if ( last !== group ) {
                                    $(rows).eq( i ).before(
                                        '<tr class="group"><td colspan="50">'+group+'</td></tr>'
                                    );

                                    last = group;
                                }
                            } );
                        },
                        "columnDefs": [

                            { "visible": false, "targets": 2 },

                            {
                                "render": function ( data, type, row ) {

                                    return data+'<a class="infoBtn"><i class="fa fa-plus-circle"></i></a> N/A';
                                },
                                targets: '_all',
                            }

                        ],
                        fixedColumns:   true,

                    } );

0 个答案:

没有答案