跳至内容
菜单
此问题已终结
1 回复
5137 查看

Hi,

I have this bit of code:

%for analysis in inv.x_tcc_analysis_ids :   
            <td width="20%" style="text-align:left;border:1px solid #555;border-left:none;padding-top: 8px;">
              <table width="100%" cellspacing="0" cellpadding="10px">
                  <tbody>
                    <tr><td style="text-align:center;border:none;border-bottom:1px solid #555;;">Year ${ analysis.x_year or '' |entity }</td></tr>
                    <tr><td style="text-align:right;border:none;border-bottom:1px dashed #555;">N ${ formatLang(analysis.x_total_income) or ''|entity }</td></tr>
                    <tr><td style="text-align:right;border:none;border-bottom:1px dashed #555;">N ${ formatLang(analysis.x_tax_paid) or '' |entity }</td></tr>
                    <tr><td style="text-align:right;border:none;border-bottom:1px dashed #555;">${ analysis.x_gitr_number or '' |entity }</td></tr>
                    <tr><td style="text-align:right;border:none;border-bottom:1px dashed #555;">${ analysis.x_gitr_date or '' |entity }</td></tr>
                  </tbody>
              </table>
            </td>      
        %endfor

I'd like to be able to limit the number of iterations to 3. I've tried using the range function but no joy so far.

Any help will be hugely appreciated. Thanks

形象
丢弃
最佳答案

use this:

<% i = 0 %>
%for analysis in inv.x_tcc_analysis_ids : 
    <% i+=1 %>
    %if i == 4:
        break
    %endif
    ...
    ...
形象
丢弃
编写者

Worked nicely. Thank you.

sounds good..:)

相关帖文 回复 查看 活动
4
9月 16
9087
1
1月 16
4242
0
3月 15
4365
3
3月 15
11266
2
4月 24
2203