dqtu14636 2018-11-08 11:52
浏览 549

DataTables警告:table id = DataTables_Table_0 - 第0行请求的未知参数“4”

I have a problem for a long time. I use a web template for my developments and I often have this error on some pages where I have to display tables, for example: DataTables warning: table id = DataTables_Table_0 - Requested unknown parameter '4' for row 0 for this code :

<div class="panel panel-flat">
    <table class="table table-bordered table-hover datatable-highlight table-striped">
        <thead>
            <tr class="bg-green-600">
                <th class="text-bold" width="40px">Codes</th>
                <th class="text-bold">Libelle</th>
            </tr>
        </thead>
        <tbody>
        <?php
 
        // Cas sélection compte bancaire
        $sql = "SELECT CODE_CIB, DESCRIPTION_CIB
        FROM CODES_INTERBANCAIRES
        ORDER BY CODE_CIB";
        $req = $DB->query($sql);
        
        while ($d = $req->fetch()) {
        ?>
            <tr>
                <td><?php echo $d['CODE_CIB']; ?></td>
                <td><?php echo $d['DESCRIPTION_CIB']; ?></td>
            </tr>
        <?php
        }
        ?>
        </tbody>
    </table>
</div>

I read the recommendations made on this error but I do not see any error that I could make. I specify that on other pages it works perfectly well and on other launch I have this error and when I click on the button ok the page is displayed. Thank you for your help.

</div>
  • 写回答

1条回答 默认 最新

  • dongnuo6310 2018-11-08 12:08
    关注

    This is the datatable js code linked to my php page in the template

    /* ------------------------------------------------------------------------------
    *
    *  # Advanced datatables
    *
    *  Specific JS code additions for datatable_advanced.html page
    *
    *  Version: 1.0
    *  Latest update: Aug 1, 2015
    *
    * ---------------------------------------------------------------------------- */
    
    $(function() {
    
    
        // Table setup
        // ------------------------------
    
        // Setting datatable defaults
        $.extend( $.fn.dataTable.defaults, {
            autoWidth: false,
            columnDefs: [{ 
                orderable: false,
                width: '100px',
                targets: [ 5 ]
            }],
            dom: '<"datatable-header"fl><"datatable-scroll"t><"datatable-footer"ip>',
            language: {
                search: '<span>Filtre:</span> _INPUT_',
                lengthMenu: '<span>Nombre de lignes:</span> _MENU_',
                paginate: { 'first': 'First', 'last': 'Last', 'next': '&rarr;', 'previous': '&larr;' }
            },
            drawCallback: function () {
                $(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').addClass('dropup');
            },
            preDrawCallback: function() {
                $(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').removeClass('dropup');
            }
        });
    
    
        // Datatable 'length' options
        $('.datatable-show-all').DataTable({
            lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]]
        });
    
    
        // DOM positioning
        $('.datatable-dom-position').DataTable({
            dom: '<"datatable-header length-left"lp><"datatable-scroll"t><"datatable-footer info-right"fi>',
        });
    
    
        // Highlighting rows and columns on mouseover
        var lastIdx = null;
        var table = $('.datatable-highlight').DataTable();
         
        $('.datatable-highlight tbody').on('mouseover', 'td', function() {
            var colIdx = table.cell(this).index().column;
    
            if (colIdx !== lastIdx) {
                $(table.cells().nodes()).removeClass('active');
                $(table.column(colIdx).nodes()).addClass('active');
            }
        }).on('mouseleave', function() {
            $(table.cells().nodes()).removeClass('active');
        });
    
    
        // Columns rendering
        $('.datatable-columns').dataTable({
            columnDefs: [ 
                {
                    // The `data` parameter refers to the data for the cell (defined by the
                    // `data` option, which defaults to the column being worked with, in
                    // this case `data: 0`.
                    render: function (data, type, row) {
                        return data +' ('+ row[3]+')';
                    },
                    targets: 0
                },
                { visible: false, targets: [ 3 ] }
            ]
        });
    
    
    
        // External table additions
        // ------------------------------
    
        // Add placeholder to the datatable filter option
        $('.dataTables_filter input[type=search]').attr('placeholder','Rechercher...');
    
    
        // Enable Select2 select for the length option
        $('.dataTables_length select').select2({
            minimumResultsForSearch: "-1"
        });
        
    });

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值