显示带有选定转换的Kentico Repeater HTML属性 [英] Kentico Repeater HTML Properties showing with selected transformation
问题描述
我的HTML信封将我的中继器转换包装在TABLE标记中.在不使用JS的情况下,如何确保此HTML在选定的转换中不可见.我不反对拥有用于所选转换数据的模板,只是不确定如何做到这一点.
My HTML envelope wraps my repeater transformation in a TABLE tag. Without using JS, how do i ensure this HTML isn't visible for the selected transformation. I have no objections to have a template for the selected transformation data, just unsure how to do that.
这是我的转变:
<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>
推荐答案
考虑将表格标签从html信封中移出,并有条件地将它们呈现在转换中,如下所示:
Consider moving your table tags from the html envelope and conditionally rendering them inside your transformation like this:
// 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>" : "" %>
由于这是完全不同的转换,因此将阻止它们出现在您选择的项目转换中.
This will prevent them from appearing in your selected item transformation since it's a completely different transformation.
您可能必须将DataItemIndex和DataItemCount属性放在Eval()方法中.自从我从事ASCX转换以来已经有一段时间了.
You may have to place the DataItemIndex and DataItemCount properties within an Eval() method. It's been awhile since I've worked with ASCX transformations.
看起来您现在可以在ascx转换中使用IsFirst()
和IsLast()
方法:
Looks like you can now use the IsFirst()
and IsLast()
methods within ascx transformations:
<%# IsFirst() ? "<table>" : "" %>
// transformation code
<%# IsLast() ? "</table>" : "" %>
这篇关于显示带有选定转换的Kentico Repeater HTML属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!