Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sitefinity Template Layout Helpers. Use these in a RadListView to generate you dynamic layout wrappers around your content.
<!-- Regular Sample -->
<telerik:RadListView ID="dynamicContentListView" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
<LayoutTemplate>
<div class="sf_cols">
<asp:PlaceHolder ID="ItemsContainer" runat="server" />
</div>
</LayoutTemplate>
<ItemTemplate>
<div class='<%# Util.Out(Container) %>'>
<div class='<%# Util.In(Container) %>'>
<!-- Content Goes Here -->
</div>
</div>
</ItemTemplate>
</telerik:RadListView>
<!-- Group Sample -->
<telerik:RadListView ID="dynamicContentListView" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false" GroupPlaceholderID="GroupContainer" GroupItemCount="4">
<LayoutTemplate>
<asp:PlaceHolder ID="GroupContainer" runat="server" />
</LayoutTemplate>
<GroupTemplate>
<div class="sf_cols">
<asp:PlaceHolder ID="ItemsContainer" runat="server" />
</div>
</GroupTemplate>
<ItemTemplate>
<div class='<%# Util.Out(Container) %>'>
<div class='<%# Util.In(Container) %>'>
<!-- Content Goes Here -->
</div>
</div>
</ItemTemplate>
</telerik:RadListView>
public static class Util
{
public static string Out(RadListViewDataItem item, int colCount = -1)
{
return Util.GenerateColumnMath("sf_colsOut sf_{0}cols_{1}_{2}", item, colCount);
}
public static string In(RadListViewDataItem item, int colCount = -1)
{
return Util.GenerateColumnMath("sf_colsIn sf_{0}cols_{1}in_{2}", item, colCount);
}
public static string GenerateColumnMath(string stringFormat, RadListViewDataItem item, int colCount = -1){
var total = (colCount != -1) ? colCount : item.OwnerListView.GroupItemCount;
var index = (item.DataItemIndex + 1);
var size = 100 / total;
//index = index % total + 1;
while (index > total)
{
index = index - total;
}
if (total == 3 && index == 2)
size = 34;
string className = String.Format(stringFormat,total,index,size);
return className;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment