Drop down custom Property (dynamic)

Vote:
 

hi

we are upgrading our EPi6 to version 7.5 and we a bunch of old custom properties. one of these is a generic drop down where according to the description ( we placed an page id there)

went and fetched all pages under the node id and created a key and value list.

i was searching around and saw two exmaple the first one with enum or "hard coded" values and the 2nd one something complicated with json fetching.

what is the correct way to create such a thing ( setting dynamic root id to drop down values)?

should i create a code with a js code that will handle a custom code ?

or should i try BackingType ?

#112738
Nov 05, 2014 0:28
Vote:
 

How dynamic do you want the values to be? If you use the SelectOne attribute you get a call to a class to create the values. This cannot take the current model into consideration however. Do you need to get dynamic values depending on another property? In that case this blog post might be something for you:

http://world.episerver.com/Blogs/Duong-Nguyen/Dates/2014/1/Country-Region-drop-down-lists-in-All-properties-mode/

If none of the options suggested matches your need, please tell how dynamic the options need to be...

#112742
Nov 05, 2014 6:15
Vote:
 

what we did in epi 6 was to create a base drop down that new how to get it's content from a page id. 

we have also created some massive custom proprties that created html in the edit mode, 

the question is the backing type: if i set a backing type will it render using the old "createeditcontrol" ?`

#112755
Nov 05, 2014 10:14
Vote:
 

You can use UIHint.Legacy on your property to trigger legacy editing. Note that this editor will be opened in a dialog, so it's not the best editor experience.

The SelectionFactory gets a reference to the metadata object and you can get the content object from there. If you want to be able to handle this for items nestled within blocks and local content objects you can use the following helper methods that EPiServers UI uses:

In your selection factory's GetSelections method:

var topMostMetadata = ((ContentDataMetadata)metadata).FindTopMostContentMetadata();

And these are the extension methods:


public static ExtendedMetadata FindTopMostContentMetadata(this ExtendedMetadata metadata)
{
return metadata.Parent.FindTopMostContentMetadata(new List<string>());
}


public static ExtendedMetadata FindTopMostContentMetadata(this ExtendedMetadata metadata, IList<string> fullPropertyName)
{
var isContent = metadata.Model is IContent;
if (metadata.Parent == null && isContent)
return metadata;

fullPropertyName.Insert(0, metadata.PropertyName);

return metadata.Parent.FindTopMostContentMetadata(fullPropertyName);
}

#112764
Nov 05, 2014 11:19
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.