Is it possible in Sitecore 7.5 to bind all the names in a Name Value Lookup to a datasource?
For example the name will be represented as a dropdown list.
This is not possible out of the box, you will need to create a custom field in order to achieve this.
I've previously blogged about a custom Name Value Lookup field, which allows the key portion of the list to be datasource driven and only selectable from a dropdown list.
All the code is available in this Github Gist, but essentially:
Sitecore.Shell.Applications.ContentEditor.NameLookupValue
OnLoad
method (inherited from base of above), and provide your own implementations of LoadValue()
and BuildControl()
. LoadValue()
code has a regex validation in there which disallows dashes (i.e. not good for GUIDs)BuildControl()
method calls through to generate the required markup of your control. In the case of this custom field, line 112 is where the call is made to get the collection of items based on the datasource value and then build the dropdown list. Modify the logic and markup as required.There is also a more recent post that builds on the above and allows use of Datasource queries to resolve the list, if that is a requirement.
Not really, no. But I've used a custom field type many times that sort of does what you ask.
It's called Unbound Droplist.
It basically allows you to set a pipe delimited string as values in a droplist. Like red|white|orange
. It's not quite what you ask, but I would need to know more about what you're trying to accomplish to narrow an answer down further.