开发者

Equal row lengths in a table

I have a table made of of several records, with the rows having different 开发者_C百科number of records per row. What I'd like to have is for the rows with less records, I want to have them being equal in length to the longest row. Currently what I have comes out like below:

Equal row lengths in a table

I've done this using this bit of code:

<table>            
    {% for week in month_days %}
        {% for day, entries, weekday in week %}
            <tr class="{% cycle 'row1' 'row2' %}">
                {% if day != 0 %}
                    <td>{{ weekday }}</td>
                    <td>{{ day }}</td>
                    {% if entries %}
                        {% for entry in entries %}
                            <td>{{ entry.start_time|time:"h:i a" }}</td>
                            <td>{{ entry.end_time|time:"h:i a" }}</td>
                            <td>{{ entry.hours }}</td>
                            <td>Break</td>
                        {% endfor %}
                    {% endif %}
               {% endif %}
           </tr>
           <!--- Insert blank row after each Sunday -->
           {% if weekday == "Sunday" %}
               <tr class="week-end">
                   <td colspan="{{ days_month.count }}">&nbsp;</td>
               </tr>
           {% endif %}
     {% endfor %}
 {% endfor %}
 </table>

From the above photo, as an example, I want, on the entry for Monday 16th, to have the blue space filled in with blank cells.


Try this:

                {% if entries %}
                    {% for entry in entries %}
                        <td>{{ entry.start_time|time:"h:i a" }}</td>
                        <td>{{ entry.end_time|time:"h:i a" }}</td>
                        <td>{{ entry.hours }}</td>
                        <td>Break</td>
                    {% endfor %}
                {% else %}
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                {% endif %}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜