跳至內容
選單
此問題已被標幟
1 回覆
5139 瀏覽次數

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
4245
0
3月 15
4369
3
3月 15
11280
2
4月 24
2204