Extjs 如何在itemTpl Sencha Touch中查找父循环的索引
我有一个表,每行都有复选框。我无法同时选择多个复选框。以下是第三方物流项目代码,供参考:Extjs 如何在itemTpl Sencha Touch中查找父循环的索引,extjs,sencha-touch,Extjs,Sencha Touch,我有一个表,每行都有复选框。我无法同时选择多个复选框。以下是第三方物流项目代码,供参考: +'<tpl for="rows">' + '<tr>' +'<tpl for="columns">' +'<tpl if="dataIndex== \'checkbox\'">' + '<td><input type="checkbox" id="checkbox{#}" class="regular-ch
+'<tpl for="rows">'
+ '<tr>'
+'<tpl for="columns">'
+'<tpl if="dataIndex== \'checkbox\'">'
+ '<td><input type="checkbox" id="checkbox{#}" class="regular-checkbox" /><label class="m0" for="checkbox{#}"></label></td>'
+'<tpl else>'
+'<td><p>{value}</p></td>'
+'</tpl>'
+'</tpl>'
+'</tr>'
+'</tpl>'
+''
+ ''
+''
+''
+ ''
+''
+“{value}”
+''
+''
+''
+''
我在获取项目Tpl中行循环的索引时遇到了一个问题,即每个复选框都有一个唯一的id。有人能告诉我该怎么做吗?支持逐字记录块(语法{%…%}
)。这些块中包含的任何代码都将直接插入为模板生成的代码中
因此,在父循环中,您可以在存储当前索引的位置声明自己的局部变量{%var parentIndex=xindex;%}
。然后在子循环中,您可以通过{[parentIndex]}
您的完整模板代码应为:
'<tpl for="rows">'
+'{% var parentIndex = xindex; %}'
+ '<tr>'
+'<tpl for="columns">'
+'<tpl if="dataIndex== \'checkbox\'">'
+ '<td><input type="checkbox" id="checkbox{[parentIndex]}" class="regular-checkbox" /><label class="m0" for="checkbox{[parentIndex]}"></label></td>'
+'<tpl else>'
+'<td><p>{value}</p></td>'
+'</tpl>'
+'</tpl>'
+'</tr>'
+'</tpl>'
“”
+“{%var parentIndex=xindex;%}”
+ ''
+''
+''
+ ''
+''
+“{value}”
+''
+''
+''
+''
非常感谢您的帮助:)它在2016年12月帮助了我:D