Print only first row from table

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%">{{ _(&quot;Description&quot;)}}</th>
			<th style="width:35%">{{_(&quot;Picture&quot;)}}</th>
			<th style="width:15%">{{_(&quot;Quantity&quot;)}}</th>
			<th style="width:15%">{{_(&quot;Price&quot;)}}</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(&quot;rate&quot;, doc) or &#39;&#39;}}</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