Created
October 28, 2011 11:10
-
-
Save hanssens/1322078 to your computer and use it in GitHub Desktop.
[MVC3/RAZOR] MultiColumnRepeaterExtension
This file contains 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 void MultiColumnRepeater<T>(this HtmlHelper helper, IEnumerable<T> model, int columnCount, Action rowHeader, Action<T> itemTemplate, Action rowFooter) | |
{ | |
int currentColumn = 0; | |
foreach (T item in model) | |
{ | |
if (currentColumn == 0) | |
rowHeader(); | |
itemTemplate(item); | |
++currentColumn; | |
if (currentColumn >= columnCount) | |
{ | |
rowFooter(); | |
currentColumn = 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment