Kentico Repeater HTML 显示所选转换的属性
Kentico Repeater HTML Properties showing with selected transformation
我的 HTML 信封将我的转发器转换包装在 TABLE 标签中。如果不使用 JS,我如何确保此 HTML 对于所选转换不可见。我不反对为选定的转换数据创建一个模板,只是不确定该怎么做。
这是我的转换:
<tr>
<td><%# FormatDate(Eval("Date")) %></td>
<td><a href="<%# GetDocumentUrl() %>"><%# Eval("Subject") %></a></td>
<td><%# Eval("From") %></td>
</tr>
这是我选择的转换:
<section id="memoDetail">
<h1>Memorandum</h1>
<ul id="memoHeader">
<li><span class="headerLabel">To:</span> <%# Eval("To") %></li>
<li><span class="headerLabel">From:</span> <%# Eval("From") %></li>
<li><span class="headerLabel">Subject:</span> <%# Eval("Subject") %></li>
<li><span class="headerLabel">Date:</span> <%# Eval("Date") %></li>
</ul>
<div id="memoDetails"><%# Eval("Details") %></div>
</section>
考虑将 table 标签从 html 信封中移出,并有条件地将它们渲染到您的转换中,如下所示:
// If this is the first item in the repeater, open the table tag
<%# DataItemIndex == 0 ? "<table>" : "" %>
// your trasformation code
// if this is the last item in the repeater, close the table tag
<%# DataItemIndex + 1 == DataItemCount ? "</table>" : "" %>
这将阻止它们出现在您选择的项目转换中,因为这是一个完全不同的转换。
您可能必须将 DataItemIndex 和 DataItemCount 属性放在 Eval() 方法中。我已经有一段时间没有使用 ASCX 转换了。
编辑: 看起来您现在可以在 ascx 转换中使用 IsFirst()
和 IsLast()
方法:
<%# IsFirst() ? "<table>" : "" %>
// transformation code
<%# IsLast() ? "</table>" : "" %>
如果列表和详情页类型不同。另一种解决方案是在中继器的 html 信封 属性 中使用宏。例如,如果列表的页面类型为 CMS.MenuItem,则 属性 应如下所示:
{% ClassName == "CMS.MenuItem" ? "<table>" : "" #%}
我的 HTML 信封将我的转发器转换包装在 TABLE 标签中。如果不使用 JS,我如何确保此 HTML 对于所选转换不可见。我不反对为选定的转换数据创建一个模板,只是不确定该怎么做。
这是我的转换:
<tr>
<td><%# FormatDate(Eval("Date")) %></td>
<td><a href="<%# GetDocumentUrl() %>"><%# Eval("Subject") %></a></td>
<td><%# Eval("From") %></td>
</tr>
这是我选择的转换:
<section id="memoDetail">
<h1>Memorandum</h1>
<ul id="memoHeader">
<li><span class="headerLabel">To:</span> <%# Eval("To") %></li>
<li><span class="headerLabel">From:</span> <%# Eval("From") %></li>
<li><span class="headerLabel">Subject:</span> <%# Eval("Subject") %></li>
<li><span class="headerLabel">Date:</span> <%# Eval("Date") %></li>
</ul>
<div id="memoDetails"><%# Eval("Details") %></div>
</section>
考虑将 table 标签从 html 信封中移出,并有条件地将它们渲染到您的转换中,如下所示:
// If this is the first item in the repeater, open the table tag
<%# DataItemIndex == 0 ? "<table>" : "" %>
// your trasformation code
// if this is the last item in the repeater, close the table tag
<%# DataItemIndex + 1 == DataItemCount ? "</table>" : "" %>
这将阻止它们出现在您选择的项目转换中,因为这是一个完全不同的转换。
您可能必须将 DataItemIndex 和 DataItemCount 属性放在 Eval() 方法中。我已经有一段时间没有使用 ASCX 转换了。
编辑: 看起来您现在可以在 ascx 转换中使用 IsFirst()
和 IsLast()
方法:
<%# IsFirst() ? "<table>" : "" %>
// transformation code
<%# IsLast() ? "</table>" : "" %>
如果列表和详情页类型不同。另一种解决方案是在中继器的 html 信封 属性 中使用宏。例如,如果列表的页面类型为 CMS.MenuItem,则 属性 应如下所示:
{% ClassName == "CMS.MenuItem" ? "<table>" : "" #%}