Last active
December 19, 2015 04:38
-
-
Save sitefinitysteve/5898325 to your computer and use it in GitHub Desktop.
Sitefinity Template Layout Helpers. Use these in a RadListView to generate you dynamic layout wrappers around your content.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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