如何在烧瓶中自动添加行 html table

how to automatically add rows in flask html table

我想在每次添加新的“待办事项”时自动添加一行。

这是目前的样子,

这里是我想要的样子 - 在“CARD_1”

我知道我哪里出了问题,从我的代码中我们可以看到 for 循环在一行下重新迭代。我想让它在我的 Trello 卡片更新时自动添加一行。

我的代码:

<table BORDER=1 WIDTH="100%" CELLPADDING="4" CELLSPACING="3">
                <thead>
                    <tr ALIGN="center">
                        <th COLSPAN="4" WIDTH="50%" CELLPADDING="4" CELLSPACING="3">
                            <br>
                            <h1>To-do list</h1>
                            </br>
                        </th>
                    </tr>
                    <tr ALIGN="center ">
                        <td ALIGN="left "><strong>Agenda</strong></td>
                        <td><strong>Not Started</strong></td>
                        <td><strong>In Progress</strong></td>
                        <td><strong>Complete</strong></td>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                            {%for item in todo_items%}
                            <td>{{item.name}}</td>
                            <td><input type="checkbox" id="id" name="Tick" value="{{item.id}}"></td>
                            <td><input type="checkbox" id="id" name="Tick" value="{{item.id}}"></td>
                            <td><input type="checkbox" id="id" name="Tick" value="{{item.id}}"></td>
                            {%endfor%}
                        </tr>
                        {% for row in todo_items%}
                        <tr>
                            {%for rwo in cell%}
                            <td>{{cell}}</td>
                            {%endfor%}
                        </tr>
                        {%endfor%}
                    </tbody>
            </table>

您可以在循环内移动“tr”标签:

<tbody>
   {%for item in todo_items%}
     <tr>
        <td>{{item.name}}</td>
        <td><input type="checkbox" id="id" name="Tick" value="{{item.id}}"></td>
        <td><input type="checkbox" id="id" name="Tick" value="{{item.id}}"></td>
        <td><input type="checkbox" id="id" name="Tick" value="{{item.id}}"></td>
      </tr>
    {%endfor%}
 </tbody>

因为定义新 table 行的是“tr”。

P.s。你想用这个达到什么目的?

{% for row in todo_items%}
  <tr>
    {%for rwo in cell%}
      <td>{{cell}}</td>
    {%endfor%}
  </tr>
{%endfor%}