next data not collapsing ? why

next data not collapsing ? why

bagas.aji838bagas.aji838 Posts: 4Questions: 1Answers: 0


Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954
    Answer ✓

    According to the information element Datatables sees only one row in the table. Without seeing your page its hard to say what is causing the issue.

    Likely causes are you have more than one tbody element in the table, see the HTML requirements for details. Or you added a row without using Datatables APIs like row.add() so Datatables doesn't know about the new row.

    If you need help debugging please post a link to your page or a test case replicating the issue so we can see what you have.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • bagas.aji838bagas.aji838 Posts: 4Questions: 1Answers: 0
    edited March 2023
    <table id="myTable-1" class="display table" style="width: 100%;">
                            <thead>
                                <tr>
                                    <th scope="col">No</th>
                                    <th scope="col">ID</th>
                                    <th scope="col">Nama</th>
                                    <th scope="col">KTP</th>
                                    <th scope="col">Whatsapp</th>
                                    <th scope="col">Gmail</th>
                                    <th scope="col">Track</th>
                                    <th scope="col">Aksi</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $no = 1;
                                foreach ($customer as $row) : ?>
                                    <tr>
                                        <th scope="row"><?= $no; ?></th>
                                        <td><?= $row['customer_id']; ?></td>
                                        <td><?= $row['nama']; ?></td>
                                        <td><?= $row['ktp']; ?></td>
                                        <td><?= $row['whatsapp']; ?></td>
                                        <td><?= $row['email']; ?></td>
                                        <td><?= $row['gmaps']; ?></td>
                                        <td>
                                            <button type="button" class="btn btn-warning text-light" data-bs-toggle="modal" data-bs-target="#<?= $update; ?><?= $no ?>">
                                                <i class="fa-regular fa-pen-to-square"></i>
                                            </button>
                                            <button type="button" class="btn btn-danger text-light" data-bs-toggle="modal" data-bs-target="#<?= $delete; ?><?= $no ?>">
                                                <i class="fa-solid fa-trash"></i>
                                            </button>
                                        </td>
                                    </tr>
                            </tbody>
    

    Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    I'm not familiar with PHP but I believe you need a <?php tag to designate where the foreach loop ends. Looks like you have the </tbody> tag within the loop. You can use the browser's inspect tool to see the resulting HTML table.

    kevin

  • bagas.aji838bagas.aji838 Posts: 4Questions: 1Answers: 0

    when i used it the first time it was running, but after i created a new page with the same table id, data table got error, thank u man

Sign In or Register to comment.