views:

24

answers:

1

I have a table made of of several records, with the rows having different 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:

alt text

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.

A: 

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 %}
Aaron Digulla
@Aaron: Sorry it took a while to reply...anyway, that edit only adds three blank cells where there are no records.
Stephen
Well, you must either make 1) the last cell extend to the right border or 2) add one empty cell that is as wide as the three above them or 3) three empty cells. Which one do you want?
Aaron Digulla
I'll see which of these three is easier...I'm remodelling the retrieving of the records, so maybe this will also simplify the issue. Thank you for your help Aaron
Stephen