However i can't help but notice the simplicity of Ernst's example which unfortunately doesn't work - In debug mode i can only see that the TopPicksRepository node and not the "items" under it.
@foreach (var item in Model.TopPicksRepository){<li>@item.InnerText</li>}
This doesn't work either.
@foreach (var item in Model.TopPicksRepository.items)
{
<li>@item.InnerText</li>
}
i like to keep my C# away from my razor view so i got a clean and nice view, just because razor can hold all your logic code there is no excuse for mixing presentation and logic
if u dont need some filtering on u items u could just use
public static DynamicNodeList MultiNodePicker(this RazorLibraryCore library, DynamicXml dynamicXml)
{
var list = new DynamicNodeList();
foreach (dynamic item in dynamicXml)
{
list.Add(new DynamicNode(item.InnerText));
}
return list;
}
if u need some filtering on your nodes make a normal static extension that dont work on the RazorLibraryCore but still passes the the dynamicXml, do the filtering there and returns your filtered nodelist that way u can have a clean foreach loop where u pressentation dont have to test for empty string and what not :)
How to retrieve nodeId from MNTP?
I've got the following items in my MTNP:
I'm trying various code to try and retrieve the nodeIds without any success. I'm going along the route of:
foreach(var v in Model.TopPicksRepository.Items.Children)
foreach(var v in Model.TopPicksRepository.Items.MultiNodePicker.Children)
Can anyone point me in the right direction?
Hi Anton,
There's a hepler method in uQuery (GetNodesByXml) to get a collection of the selected nodes from an MNTP xml fragment:
HTH,
Hendy
The following should list the items/id's in a MNTP with the alias TopPicksRepository.
@foreach (var x in Model.TopPicksRepository){ @x.InnerText }
The code by Hendy works great - Thanks.
However i can't help but notice the simplicity of Ernst's example which unfortunately doesn't work - In debug mode i can only see that the TopPicksRepository node and not the "items" under it.
This doesn't work either.
i like to keep my C# away from my razor view so i got a clean and nice view, just because razor can hold all your logic code there is no excuse for mixing presentation and logic
if u dont need some filtering on u items u could just use
if u need some filtering on your nodes make a normal static extension that dont work on the RazorLibraryCore but still passes the the dynamicXml, do the filtering there and returns your filtered nodelist that way u can have a clean foreach loop where u pressentation dont have to test for empty string and what not :)
is working on a reply...