DataTables Sort Not Working: What Could Be the Issue? - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Monday, September 11, 2023

DataTables Sort Not Working: What Could Be the Issue?

I have this table error when i tried to Sort the data using sort fiture by datatables it just change the 1st line of data and the other data stay the same as it is doesnt get sorted at all, and because this error it messed up many thing such as download file from some id that make all the data share the same id even thought it shouldnt. so here's an example of my datatables code

<table id="datatablesSimple">
                            <thead>
                                <tr>
                                    <th>Username</th>
                                    <th>Nama</th>
                                    <th>Identitas</th>
                                    <th>Kelola</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <?php
                                    $no = 1;
                                    $data = mysqli_query($koneksi, "select * from user Order by identitas ASC");
                                    while ($d = mysqli_fetch_array($data)) {
                                    ?>
                                        <td><?php echo $d['username']; ?></td>
                                        <td><?php echo $d['nama']; ?></td>
                                        <td><?php echo ucwords($d['identitas']); ?></td>
                                        <td>
                                            <center>
                                                <?php
                                                echo '<div class="data-item">';
                                                echo '<button class="btn btn-primary edit-btn fas fa-pen-to-square" data-toggle="modal" data-target="#editModal" data-username="' . $d['username'] . '">Edit</button>';
                                                echo '<button class="btn btn-danger delete-btn fas fa-trash" data-toggle="modal" data-target="#deleteConfirmationModal" data-username="' . $d['username'] . '">Hapus</button>';
                                                echo '</div>';
                                                ?>

                                                <!-- Delete Confirmation Modal -->
                                                <div class="modal fade" id="deleteConfirmationModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                                    <div class="modal-dialog" role="document">
                                                        <div class="modal-content">
                                                            <div class="modal-header">
                                                                <h5 class="modal-title" id="exampleModalLabel">Confirm Deletion</h5>
                                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                                    <span aria-hidden="true">&times;</span>
                                                                </button>
                                                            </div>
                                                            <div class="modal-body">
                                                                Apa anda yakin ingin menghapus data ini ?
                                                            </div>
                                                            <div class="modal-footer">
                                                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                                                                <a id="deleteLink" href="#" class="btn btn-danger">Delete</a>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </center>
                                        </td>
                                </tr>
                            <?php
                                    }
                            ?>
                            </tbody>
                        </table>

here's an image for the error example

Image 1 Image 2

Thanks.

i've tried modifying the table to some extent, and i've tried to change the library etc.



source https://stackoverflow.com/questions/77077183/datatables-sort-not-working-what-could-be-the-issue

No comments:

Post a Comment