未捕获的typeerror:无法读取jquery数据表中未定义的属性“style”

ecbunoof  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(169)

在此处输入图像描述我正在通过ajax调用获取datatables数据,但出现以下错误。你能帮我解决这个问题吗。

Uncaught TypeError: Cannot read property 'style' of undefined  
       at _fnCalculateColumnWidths (datatables.bundle.js:5647)  
       at _fnInitialise (datatables.bundle.js:4761)  
       at loadedInit (datatables.bundle.js:1299)  
       at HTMLTableElement.<anonymous> (datatables.bundle.js:1311)  
       at Function.each (core.js:260)  
       at jQuery.fn.init.each (core.js:82)  
       at jQuery.fn.init.DataTable [as dataTable] (datatables.bundle.js:869)  
       at jQuery.fn.init.$.fn.DataTable (datatables.bundle.js:15214)  
       at initTable2 (8:2711)  
       at Object.init (8:2860)

我试过:

var KTDatatablesExtensionButtons = function() {
    var initTable2 = function() {
            var table = $('#kt_table_1').DataTable({
            "ajax": {
                url : "<?php echo base_url(); ?>tableform/datashow/"+formid,
                type : 'POST',
                'data': function(data){
                    var arr = [];
                    $('.ajaxcols').each(function() { 
                        var datas  = $(this).val(); 
                        var columns = $(this).attr('data-column'); 
                        if(datas != ''){arr.push({data: datas, column :columns});}
                    });
                    if(arr.length != 0){data.searchByArray = JSON.stringify(arr);}
                }
             },"columns": <?php echo $tablecolumns; ?>,
                "orderCellsTop": true,"serverSide": true,"responsive": false,"colReorder": true,
                "dom": "<'row'<'col-sm-3 text-left'f><'col-sm-6 text-right'>>\
                <'row'<'col-sm-12'tr>>\
                <'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7 dataTables_pager'lp>>",
                select: {selector:'td:not(:nth-child(2))',style:'multi'},
                layout: {scroll: true,height: 550,footer: false},
                rows: {autoHide: false,},
                columnDefs: [{"targets": [ 6,7,15,21 ],"visible": false,"className": 'noVis',}],
            });
            table.columns.adjust().draw();
        };
        return {init: function() {initTable2();}};
    }();
    jQuery(document).ready(function() {
        $('#kt_table_1').DataTable().destroy();
        KTDatatablesExtensionButtons.init();
    });

上面的代码无法解决我的问题。请帮帮我,谢谢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题