I need to show subitems of a node. A simple foreach would do the trick. But i need a limited amount. Max 5 items. If there are more the 5 items it should show a "see all" link.(parent node). If only 3 subitems, the "see all" node should not bu shown ofcourse. Working in v8
You could use a simple counter variable, like so - and then apply whatever logic you need based on this. For example, if the counter is 5, then show "see more".
@{
int counter = 1;
foreach (var i in Model.Children)
{
// Apply your own logic based on the counter
// e.g - if counter == 5, show see all
counter++;
}
}
limited list - see all link
Hi,
I need to show subitems of a node. A simple foreach would do the trick. But i need a limited amount. Max 5 items. If there are more the 5 items it should show a "see all" link.(parent node). If only 3 subitems, the "see all" node should not bu shown ofcourse. Working in v8
Any help appreciated!
You could use a simple
counter
variable, like so - and then apply whatever logic you need based on this. For example, if the counter is 5, then show "see more".Hi Josker
How about this?
Hi Søren,
Exactly how I did it! I was under the impression that the Take() only works if there are more items. But I was wrong. Thanks!
is working on a reply...