dsy6639 2015-09-21 10:19
浏览 557
已采纳

jQuery DataTables - 单击列时排序不起作用

The tabs/search bar/page entries appear at the top of the table as expected. But they are not sorted when clicked. It's like it only looks at the first row.

<script>

    $(document).ready( function () {

    $('#aeotable').DataTable();

    } );

</script>

echo '

    <table id="aeotable" class="display">
            <thead>     
                <tr>
                    <th>Company Name</th>
                    <th>Expiry insurance certificate</th>
                    <th>Comments</th>
                    <th>File Name</th>
                    <th>&nbsp;</th>
                </tr>
            </thead>';



    // Print each file
    while($row = $result->fetch_assoc()) {
        echo "
        <tbody>
            <tr>
                <td>{$row['cop']}</td>
                <td>{$row['expo']}</td>
                <td>{$row['dec']}</td>
                <td>{$row['fil']}</td>
                <td><a download href=\"file/{$row['file']}\">Download</a></td>


            </tr>
        </tbody>";
    }

    // Close tabl
    echo '</table>';
  • 写回答

1条回答 默认 最新

  • dsxgby126001 2015-09-21 10:31
    关注

    You are creating a <tbody> for each row instead of one <tbody> for all rows.

    Change to

    echo '<tbody>';
    // Print each file
    while($row = $result->fetch_assoc()) {
        echo "        
            <tr>
                <td>{$row['cop']}</td>
                <td>{$row['expo']}</td>
                <td>{$row['dec']}</td>
                <td>{$row['fil']}</td>
                <td><a download href=\"file/{$row['file']}\">Download</a></td>
            </tr>";
    } 
    
    echo ' </tbody>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 求用matlab求解上述微分方程的程序代码
  • ¥15 请问各位,如何在Jetson nano主控板的Ubuntu系统中安装PyQt5
  • ¥15 MAC安装佳能LBP2900驱动的网盘提取码
  • ¥400 微信停车小程序谁懂的来
  • ¥15 ATAC测序到底用什么peak文件做Diffbind差异分析
  • ¥15 安装ubantu过程中第一个vfat 文件挂载失败
  • ¥20 GZ::CTF如何兼容一些靶机?
  • ¥15 etcd集群部署问题
  • ¥20 谁可以帮我一下问一下各位
  • ¥15 为何重叠加权后love图的SMD与svyCreateTableOne函数绘制基线表的不一致