Hi,
Is there any way to only print the first row of a child table, even the item table have 2 or more rows?
<table border="1" cellpadding="2" cellspacing="2" style="line-height: 2em;width: 100%;">
<thead>
<tr>
<th style="width:35%">{{ _("Description")}}</th>
<th style="width:35%">{{_("Picture")}}</th>
<th style="width:15%">{{_("Quantity")}}</th>
<th style="width:15%">{{_("Price")}}</th>
</tr>
</thead>
<tbody>
<tr>{%- for row in doc.items-%}
<td>{{ row.item_name}} {{ row.description}}</td>
<td style="width: 57%;"><img src="{{ row.image }}" style="max-width: 100%" /></td>
<td>{{ row.qty}}</td>
<td>{{ row.get_formatted("rate", doc) or ''}}</td>
</tr>{%- endfor -%}
</tbody>
</table>
Regards.
Just a guess, not sure if this will work…
1 Like
No, it didn’t worked
File "<unknown>", line 11, in template
TemplateSyntaxError: expected name or number
Hi, Put this condition.
{{ ("Description")}}
{{("Picture")}}
{{("Quantity")}}
{{("Price")}}
{%- for row in doc.items-%}
{% if loop.index == 1 %}
{{ row.item_name}} {{ row.description}}
{{ row.qty}}
{{ row.get_formatted("rate", doc) or ''}}
{% endif %}
{%- endfor -%}
3 Likes
It works perfectly!
THANKS!!!
Please make it as solution