Droptree Properties

Droptree Properties

Droptree Fields

  • Store field values as GUID
  • There is no web control for use in declarative markup
  • Not supported by FieldRenderer.Render() method or FieldRenderer control
  • Supported by Sitecore.Data.Fields.ReferenceField class in Sitecore API
  • Does not natively support displaying field values in the Page Editor

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Context
  • Sitecore.Data.Database
  • Sitecore.Data.Fields.ReferenceField
  • Sitecore.Data.Items.Item
  • Sitecore.MainUtil


Droptree Fields C# Web Control Code

//get Link Fields metadata item from context database using item guid
Sitecore.Data.Database db = Sitecore.Context.Database;
Sitecore.Data.Items.Item item = db.GetItem("{E3B7CC3C-8C55-4401-A3C9-0FEA9CDA3E9C}");
if (item == null) return;
Sitecore.Data.Fields.ReferenceField droptreeFld = item.Fields["example droptree"];
if (droptreeFld == null) return;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Real-time Output");
output.RenderEndTag();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
//using : for colon and   for space
output.Write("{0}: {1}", "Item", item.DisplayName);
output.RenderEndTag(); //P

output.Write("Path: " + "<b>" + droptreeFld.Path + "</b><br/>"); 
output.Write("Target ID: " + "<b>" + droptreeFld.TargetID.ToString() + "</b><br/>"); 
output.Write("Target Item Name: " + "<b>" + droptreeFld.TargetItem.Name + "</b><br/>"); 
output.Write("Can Read? " + "<b>" + droptreeFld.InnerField.CanRead.ToString() + "</b><br/>"); 
output.Write("Can Write? " + "<b>" + droptreeFld.InnerField.CanWrite.ToString() + "</b><br/>"); 
output.Write("Contains Standard Value? " + "<b>" + droptreeFld.InnerField.ContainsStandardValue.ToString() + "</b><br/>"); 
output.Write("Definition: " + "<b>" + droptreeFld.InnerField.Definition.Name + "</b><br/>"); 
output.Write("Description: " + "<b>" + droptreeFld.InnerField.Description + "</b><br/>"); 
output.Write("Display Name: " + "<b>" + droptreeFld.InnerField.DisplayName + "</b><br/>"); 
output.Write("Has Blob Stream? " + "<b>" + droptreeFld.InnerField.HasBlobStream.ToString() + "</b><br/>"); 
output.Write("Has Value? " + "<b>" + droptreeFld.InnerField.HasValue.ToString() + "</b><br/>"); 
output.Write("ID: " + "<b>" + droptreeFld.InnerField.ID.ToString() + "</b><br/>"); 
output.Write("Contains Inherited Value? " + "<b>" + droptreeFld.InnerField.InheritedValue + "</b><br/>"); 
output.Write("Is Blob Field? " + "<b>" + droptreeFld.InnerField.IsBlobField.ToString() + "</b><br/>"); 
output.Write("Has Been Modified? " + "<b>" + droptreeFld.InnerField.IsModified.ToString() + "</b><br/>"); 
output.Write("Key: " + "<b>" + droptreeFld.InnerField.Key + "</b><br/>"); 
output.Write("Language: " + "<b>" + droptreeFld.InnerField.Language.Name + "</b><br/>"); 
output.Write("Name: " + "<b>" + droptreeFld.InnerField.Name + "</b><br/>"); 
output.Write("Reset Blank On? " + "<b>" + droptreeFld.InnerField.ResetBlank.ToString() + "</b><br/>"); 
output.Write("Section Name: " + "<b>" + droptreeFld.InnerField.Section + "</b><br/>"); 
output.Write("Sort Order: " + "<b>" + droptreeFld.InnerField.Sortorder.ToString() + "</b><br/>"); 
output.Write("Shared? " + "<b>" + droptreeFld.InnerField.Shared.ToString() + "</b><br/>"); 
output.Write("Source: " + "<b>" + droptreeFld.InnerField.Source + "</b><br/>"); 
output.Write("Title: " + "<b>" + droptreeFld.InnerField.Title + "</b><br/>"); 
output.Write("Tooltip: " + "<b>" + droptreeFld.InnerField.ToolTip + "</b><br/>"); 
output.Write("Translatable? " + "<b>" + droptreeFld.InnerField.Translatable.ToString() + "</b><br/>"); 
output.Write("Type: " + "<b>" + droptreeFld.InnerField.Type + "</b><br/>"); 
output.Write("Type Key: " + "<b>" + droptreeFld.InnerField.TypeKey + "</b><br/>"); 
output.Write("Unversioned? " + "<b>" + droptreeFld.InnerField.Unversioned.ToString() + "</b><br/>"); 
output.Write("Validation Regex: " + "<b>" + droptreeFld.InnerField.Validation + "</b><br/>"); 
output.Write("Validation Message: " + "<b>" + droptreeFld.InnerField.ValidationText + "</b><br/>"); 
output.Write("Value: " + "<b>" + droptreeFld.InnerField.Value + "</b>");

output.RenderEndTag(); //Div


Droptree Properties C# Web Control Output

Path: {FF343316-75E0-49F1-BA22-64175B3471A3}
Target ID: {FF343316-75E0-49F1-BA22-64175B3471A3}
Target Item Name: Devices
Can Read? True
Can Write? True
Contains Standard Value? False
Definition: Example Droptree
Description: 
Display Name: Example Droptree
Has Blob Stream? False
Has Value? True
ID: {A55F234B-79B2-4FE3-83FD-D3C39DF83E08}
Contains Inherited Value? {FF343316-75E0-49F1-BA22-64175B3471A3}
Is Blob Field? False
Has Been Modified? False
Key: example droptree
Language: en
Name: Example Droptree
Reset Blank On? False
Section Name: Link Fields
Sort Order: 300
Shared? False
Source: /sitecore/content/home/developers
Title: 
Tooltip: 
Translatable? False
Type: Droptree
Type Key: droptree
Unversioned? False
Validation Regex: 
Validation Message: 
Value: {FF343316-75E0-49F1-BA22-64175B3471A3}