Get options from parent node in backoffice property
Greetings,
What I want to accomplish is have some repeater field in a node, like Archetype and then on the child node have a picker that can select any (or none) of these options.
Kind of like the multinode treepicker but for values instead of nodes.
Does anyone know of an extension that can do this, or should I start with a custom property editor?
I'd appreciate if someone has faced this and can share some insight.
May not be what you are after but I would look at nuPickers, I used their DotNet PrefectchListPicker datatype to select options added via an archetype repeater on the root of my site. With this data type the options made available can be derived via a class.
My code:
public class RegionOptions : IDotNetDataSource
{
IEnumerable<KeyValuePair<string, string>> IDotNetDataSource.GetEditorDataItems(int contextId)
{
if (contextId > 0)
{
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var currentNode = new Node(contextId);
var homeNode = umbracoHelper.TypedContent(currentNode.GetAncestorByPathLevel(1).Id);
return RetrieveRegionsFromNow(homeNode);
}
else
{
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var homeNodeTest = umbracoHelper.TypedContentAtRoot().FirstOrDefault();
return RetrieveRegionsFromNow(homeNodeTest);
}
}
private IEnumerable<KeyValuePair<string, string>> RetrieveRegionsFromNow(IPublishedContent node)
{
if (node.HasValue("regions"))
{
var regions =
node.GetPropertyValue<ArchetypeModel>("regions")
.Fieldsets.Select(
fieldset => new KeyValuePair<string, string>(
Regex.Replace(fieldset.GetValue("region"), "(?: |,)", ""),
fieldset.GetValue("region")));
return regions;
}
return Enumerable.Empty<KeyValuePair<string, string>>();
}
}
Instead of getting the property from the home node you would obviously target the parent of 'currentNode'.
Other than that you will have to create something bespoke yourself.
Get options from parent node in backoffice property
Greetings,
What I want to accomplish is have some repeater field in a node, like Archetype and then on the child node have a picker that can select any (or none) of these options.
Kind of like the multinode treepicker but for values instead of nodes.
Does anyone know of an extension that can do this, or should I start with a custom property editor?
I'd appreciate if someone has faced this and can share some insight.
Thanks,
Pantelis
May not be what you are after but I would look at nuPickers, I used their DotNet PrefectchListPicker datatype to select options added via an archetype repeater on the root of my site. With this data type the options made available can be derived via a class.
My code:
Instead of getting the property from the home node you would obviously target the parent of 'currentNode'.
Other than that you will have to create something bespoke yourself.
Hello Ian,
Thanks for this, I actually went ahead with nuPickers and it was exactly what I wanted.
Plus the DotNet datatype is super easy to configure, couldn't have done it better from scratch!
Thank you,
Pantelis
is working on a reply...