I get an empty row for each object from a db, why?

I get an empty row for each object from a db, why?

papanitopapanito Posts: 2Questions: 1Answers: 0

Link to test case: N/A
Debugger code (debug.datatables.net): N/A
Error messages shown:

DataTables warning: table id=usersTable - Requested unknown parameter '0' for row 1, column 0. For more information about this error, please see https://datatables.net/tn/4

Description of problem:

When loading the page the data is ok

After clicking "OK I see this

    <link rel="stylesheet" href="https://cdn.datatables.net/2.2.1/css/dataTables.dataTables.css" />
    <script src="https://code.jquery.com/jquery-3.7.1.js"
            integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4="
            crossorigin="anonymous"></script>
    <script src="https://cdn.datatables.net/2.2.1/js/dataTables.js"></script>
    <script>
        $(document).ready(function() {
            $('#usersTable').DataTable({
                paging: true,
                ordering: true,
                searchable: true,
            });
        });
    </script>
</head>
<body>
    <h1>Users</h1>
    <table id="usersTable" border="1" class="hover order-column" data-order='[[ 1, "asc" ]]' data-page-length=10>
        <thead>
            <tr>
                <th>ID</th>
                <th>Username</th>
                <th>Name</th>
                <th>Surname</th>
                <th>Save</th>
            </tr>
        </thead>
        <tbody>
        {% for user in users %}
            <tr data-user-id="{{ user[0] }}">
                <td data-column="id">{{ user[0] }}</td>
                <td class="editable" data-column="username">{{ user[1] }}</td>
                <td class="editable" data-column="name">{{ user[2] }}</td>
                <td class="editable" data-column="surname">{{ user[3] }}</td>
                <td><button class="save-btn">Save</button></td>
            <tr>
        {% endfor %}
        </tbody>
    </table>

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,637Questions: 26Answers: 5,011
    Answer ✓

    My guess is on line 36 you have <tr> but should have a closing tag of </tr>.

    If this doesn't help then please provide a test case showing the issue. Possibly inspect the table tag with the browser's inspector tool and copy the generated HTML into a test case here:
    https://live.datatables.net/

    Kevin

  • papanitopapanito Posts: 2Questions: 1Answers: 0

    Thanks for the hint

Sign In or Register to comment.