Kentico Repeater HTML属性显示选定的转换

时间:2016-02-16 14:45:40

标签: kentico

我的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>

2 个答案:

答案 0 :(得分:4)

考虑从html信封中移动表格标签,并在转换中有条件地呈现它们,如下所示:

TypeError: Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided.

这将阻止它们出现在您选择的项目转换中,因为它是一个完全不同的转换。

您可能必须将DataItemIndex和DataItemCount属性放在Eval()方法中。自从我使用ASCX转换以来已经有一段时间了。

修改:您似乎现在可以在ascx转换中使用// 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>" : "" %> IsFirst()方法:

IsLast()

答案 1 :(得分:1)

如果列表和详细信息页面类型不同。另一种解决方案是在转发器的html信封属性中使用宏。例如,如果列表的页面类型是CMS.MenuItem,则属性应如下所示:

{% ClassName == "CMS.MenuItem" ? "<table>" : "" #%}
相关问题