Grp DList Properties

Grp DList Properties

Grouped Droplist Fields

  • Store item name or display name of selected item as raw text
  • Supported by <sc:text> web control in declarative markup
  • The Source field is required and specifies an item path in the Content Tree so the system can display the grandchild items in the droplist field organized by the child items
  • Not supported by FieldRenderer.Render() method or FieldRenderer control
  • Field supports use of Sitecore Query to filter on source property
  • 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.GroupedDroplistField
  • Sitecore.Data.Items.Item
  • Sitecore.MainUtil
  • Grouped Droplist C# Web Control Code

    //get List Fields metadata item from master database using item guid
    Sitecore.Data.Database db = Sitecore.Configuration.Factory.GetDatabase("master");
    Sitecore.Data.Items.Item item = db.GetItem("{7246223A-BFB0-41F9-8A91-1E7D931CDC43}");
    if (item == null) return;
    Sitecore.Data.Fields.GroupedDroplistField gdlFld = item.Fields["example grouped droplist"];
    if (gdlFld == null) return;

    output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Id, "snip-output-heading");
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
    output.Write("C# Code Real-time Output");
    output.RenderEndTag();

    output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Id, "snip-output");
    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 &#58; for colon and &#160; for space
    output.Write("{0}&#58;&#160;{1}", "Field", gdlFld.InnerField.DisplayName);
    output.RenderEndTag(); //P

    string canRead = gdlFld.InnerField.CanRead.ToString();
    string canWrite = gdlFld.InnerField.CanWrite.ToString();
    string containsSV = gdlFld.InnerField.ContainsStandardValue.ToString();
    string definition = gdlFld.InnerField.Definition.Name;
    string description = gdlFld.InnerField.Description;
    string displayName = gdlFld.InnerField.DisplayName;
    string hasBlobStream = gdlFld.InnerField.HasBlobStream.ToString();
    string hasValue = gdlFld.InnerField.HasValue.ToString();
    string id = gdlFld.InnerField.ID.ToString();
    string inheritedValue = gdlFld.InnerField.InheritedValue;
    string isBlobField = gdlFld.InnerField.IsBlobField.ToString();
    string isModified = gdlFld.InnerField.IsModified.ToString();
    string key = gdlFld.InnerField.Key;
    string language = gdlFld.InnerField.Language.Name;
    string name = gdlFld.InnerField.Name;
    string resetBlank = gdlFld.InnerField.ResetBlank.ToString();
    string sectionName = gdlFld.InnerField.Section;
    string sortorder = gdlFld.InnerField.Sortorder.ToString();
    string shared = gdlFld.InnerField.Shared.ToString();
    string source = gdlFld.InnerField.Source;
    string title = gdlFld.InnerField.Title;
    string tooltip = gdlFld.InnerField.ToolTip;
    string translatable = gdlFld.InnerField.Translatable.ToString();
    string type = gdlFld.InnerField.Type;
    string typekey = gdlFld.InnerField.TypeKey;
    string unversioned = gdlFld.InnerField.Unversioned.ToString();
    string validation = gdlFld.InnerField.Validation;
    string validationText = gdlFld.InnerField.ValidationText;
    string value = gdlFld.InnerField.Value;

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

    output.RenderEndTag(); //Div

    Grouped Droplist C# Web Control Output

    Can Read? True
    Can Write? True
    Contains Standard Value? True
    Definition: Example Grouped Droplist
    Description: 
    Display Name: Example Grouped Droplist
    Has Blob Stream? False
    Has Value? False
    ID: {8E5D7614-FF61-4CE7-BEF2-E81A51EF4549}
    Contains Inherited Value? ContentManagement
    Is Blob Field? False
    Has Been Modified? False
    Key: example grouped droplist
    Language: en
    Name: Example Grouped Droplist
    Reset Blank On? False
    Section Name: List Fields
    Sort Order: 300
    Shared? False
    Source: /sitecore/content/Home/ContentAuthors/Content
    Title: 
    Tooltip: 
    Translatable? False
    Type: Grouped Droplist
    Type Key: grouped droplist
    Unversioned? False
    Validation Regex: 
    Validation Message: 
    Value: ContentManagement