得到一个tal的索引:在另一个tal:repeat函数中重复

时间:2013-05-06 14:25:34

标签: plone zope chameleon template-tal

如您所见,我有3个列表:Procedur_HeadersDiagnosesList_ProcedurProcedur_headers给出了表格的标题, Diagnoses给出了过程的特定id List_Procedur是列表(查询)列表,其中包含我需要的所有数据。 现在我想要做的是在

中获得诊断页面的索引
tal:repeat="list_procedur List_Procedur[index]"

我可以在表格中获取数据。 我已经可以得到索引:

tal:content="python:repeat['diagnoses'].index"

但我不能在索引的地方这样做。 有没有人有这样的解决方案?

<table id="tableIngrepen" class="table">
    <thead class="header">
    <tr>
        <th>Code Diagnose vast</th>
        <th tal:repeat="procedur_headers Procedur_Headers" tal:content="procedur_headers" > </th>
    </tr>
    </thead>
    <tr tal:repeat="diagnoses Diagnoses"> 
        <td tal:content="python:repeat['diagnoses'].index"></td>
        <td ><input type='text' id="dz_code" class="input-mini" value="${diagnoses.code_diagnose}" onchange="voegrijtoe_Ingrepen(this.value,this);logging(this,'Code','2')" placeholder="Code"></input></td> <!-- onfocus="rijencolom($(this).parent().children().index($(this)),$(this).parent().parent().children().index($(this).parent()))" -->
        <td colspan="6">
            <table  id="tableIngrepen" class="table table-hover" style="border-style:none">
                <thead class="header">
                    <tr>
                        <th tal:repeat="procedur_headers Procedur_Headers" tal:content="procedur_headers" > </th> <!-- style="display:none"-->
                    </tr>
                </thead>
                <tr tal:repeat="list_procedur List_Procedur[index]">
                    <td style="max-width: 60px; word-wrap: break-word" >Uitleg over de Code van deze diagnose in maximaal 200 karakters</td>
                    <td ><input type='text' id="dz_Datum" class="input-small2" value="${list_procedur.code_diagnose}"  onchange="logging(this,'Datum','2');datumvalidate(this)" placeholder="yyyy-mm-dd"></input></td>
                    <td><input type='text' id="dz_dir" class="input-mini1"  onchange="logging(this,'Dir','2')" ></input></td>
                    <td><input type='text' id="dz_aan" class="input-mini1"  onchange="logging(this,'Aan','2')" ></input></td>
                    <td><input type='text' id="dz_uit" class="input-mini1"  onchange="logging(this,'Dz','2')" ></input></td>
                </tr>
                <tr>
                    <td style="max-width: 60px; word-wrap: break-word" >Uitleg over de Code van deze diagnose in maximaal 200 karakters</td>
                    <td ><input type='text' id="dz_Datum" class="input-small2"  onchange="logging(this,'Datum','2');datumvalidate(this)" placeholder="yyyy-mm-dd"></input></td>
                    <td><input type='text' id="dz_dir" class="input-mini1"  onchange="logging(this,'Dir','2')" ></input></td>
                    <td><input type='text' id="dz_aan" class="input-mini1"  onchange="logging(this,'Aan','2')" ></input></td>
                    <td><input type='text' id="dz_uit" class="input-mini1"  onchange="logging(this,'Dz','2')" ></input></td>
                </tr>
            </table>
        </td>
    </tr>
</table>

1 个答案:

答案 0 :(得分:3)

解决方案是:

<tr tal:repeat="diagnoses Diagnoses"> <div tal:omit-tag="" tal:define="myindex python:repeat['diagnoses'].index"> ..use the myindex.. </div> </tr>