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 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用