我尝试使用把手构建一个带有rowspan的表格,并且我试图让备用行颜色对我有利。
这是模板:
{{#each .}}
{{#if_even @index}}
<tr>
{{else}}
<tr class="oddrow">
{{/if_even}}
<td class="singlevaluecell" rowspan="{{#countmembers this.pools}}{{/countmembers}}">{{loadbalancer}}</td>
{{#if this.pools.length}}
{{#each this.pools}}
<td class="poolcell" rowspan="{{this.members.length}}">{{this.name}}</td>
{{#each members}}
{{#if @first}}
<td class="membercell">{{this.name}} - {{this.enabled}}</td>
</tr>
{{else}}
{{#if_even @../../index}}
<tr>
{{else}}
<tr class="oddrow">
{{/if_even}}
<td class="membercell">{{this.name}} - {{this.enabled}}</td>
</tr>
{{/if}}
{{/each}}
{{/each}}
{{else}}
<td class="poolcell">N/A</td>
<td class="membercell">N/A</td>
</tr>
{{/if}}
{{/each}}
以下是数据:
[{
"pools": [{
"name": "POOLNAME",
"members": [{
"name": "/Common/MEMBER01",
"availability": "AVAILABILITY_STATUS_GREEN"
}, {
"name": "/Common/MEMBER02",
"availability": "AVAILABILITY_STATUS_GREEN"
}],
"loadbalancer": "LBNAME"
}],
"loadbalancer": "LBNAME"
}]
在我尝试仅使用一个级别(@ .. / index)之前,这样做很好。
应该@ .. / .. / index工作吗?我还有其他的错误。我无法弄清楚。
任何建议/调试方式都将受到赞赏!
/帕特里克
答案 0 :(得分:0)
问题不是@../../index
无效,而是我的表格标记。 :)
{{#each .}}
{{#if_even @index}}
<tr>
{{else}}
<tr class="oddrow">
{{/if_even}}
<td class="singlevaluecell" rowspan="{{#countmembers this.pools}}{{/countmembers}}">{{loadbalancer}}</td>
{{#if this.pools.length}}
{{#each this.pools}}
{{#if @first}}
<td class="poolcell" rowspan="{{this.members.length}}">{{#trimpartition this.name type="hidepoolpartition"}}{{/trimpartition}}</td>
{{else}}
{{#if_even @../index}}
<tr>
{{else}}
<tr class="oddrow">
{{/if_even}}
<td class="poolcell" rowspan="{{this.members.length}}">{{#trimpartition this.name type="hidepoolpartition"}}{{/trimpartition}}</td>
{{/if}}
{{#each members}}
{{#if @first}}
<td class="membercell">{{this.name}} - {{this.enabled}}</td>
</tr>
{{else}}
{{#if_even @../../index}}
<tr>
{{else}}
<tr class="oddrow">
{{/if_even}}
<td class="membercell">{{this.name}} - {{this.enabled}}</td>
</tr>
{{/if}}
{{/each}}
{{/each}}
{{else}}
<td class="poolcell">N/A</td>
<td class="membercell">N/A</td>
</tr>
{{/if}}
{{/each}}