Quick question I have a uComponents DataType that is a XPathCheckBoxList DataType that uses a simple XPath to select nodes for this checkbox options for the user, that stores the NodeNames as XML with this simple xPath //WorkType
I wanted to use the Razor Model Data Binding feature in my Razor so I can fetch the values and iterate over them in a loop like so:
@{if (item.HasValue("servicesRendered"))
{
var services = item.servicesRendered;
<span>@foreach (var service in services)
{
@service.Name <text> / </text>
}
</span>
}
}
I am running Umbraco 4.7.1 with uComponents 4.1.0 and ensured the web.config key ucomponents:RazorModelBinding is set to true.
Hey Lee, Thanks for getting back to me. This is odd as it is returning a DynamicNodeList object but when I set a break point on the object I get no items in the collection.
Razor Model for XPathCheckboxList
Hello you wonderful uComponents Dev's.
Quick question I have a uComponents DataType that is a XPathCheckBoxList DataType that uses a simple XPath to select nodes for this checkbox options for the user, that stores the NodeNames as XML with this simple xPath //WorkType
I wanted to use the Razor Model Data Binding feature in my Razor so I can fetch the values and iterate over them in a loop like so:
I am running Umbraco 4.7.1 with uComponents 4.1.0 and ensured the web.config key ucomponents:RazorModelBinding is set to true.
So if any of you uComponent ninja's can give me some advice or pointers that wouyld be great.
Thanks,
Warren :)
Hi Warren,
Did you try the Razor script? If so, what happens?
The model-binder (in uComponents v4.x) would return the property as a DynamicNodeList object - should be able to loop it as you've already got.
Cheers, Lee.
Hey Lee,
Thanks for getting back to me. This is odd as it is returning a DynamicNodeList object but when I set a break point on the object I get no items in the collection.
See screengrab
Cheers,
Warren :)
Hmmm... what values do you have for it in your "umbraco.config"?
Hey Lee,
Here is the XML stub stored in the property
Ah ha, it's set to use Node Name as the value. Hmmm... busted - our ModelBinder wont work with it :-(
If you swap them over to use Node Id, then it will work.
- Lee
is working on a reply...