Inheritance: RockDropDownList
        /// <summary>
        /// Creates the HTML controls required to configure this type of field
        /// </summary>
        /// <returns></returns>
        public override List<Control> ConfigurationControls()
        {
            var controls = base.ConfigurationControls();

            // build a drop down list of enity types (the one that gets selected is
            // used to build a list of attributes) 
            var etp = new EntityTypePicker();
            controls.Add( etp );
            etp.AutoPostBack = true;
            etp.SelectedIndexChanged += OnQualifierUpdated;
            etp.Label = "Entity Type";
            etp.Help = "The Entity Type to select attributes for.";

            var entityTypeList = new Model.EntityTypeService( new RockContext() ).GetEntities().ToList();
            etp.EntityTypes = entityTypeList;

            // Add checkbox for deciding if the defined values list is renedered as a drop
            // down list or a checkbox list.
            var cb = new RockCheckBox();
            controls.Add( cb );
            cb.AutoPostBack = true;
            cb.CheckedChanged += OnQualifierUpdated;
            cb.Label = "Allow Multiple Values";
            cb.Text = "Yes";
            cb.Help = "When set, allows multiple attributes to be selected.";
            return controls;
        }
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Controls.Clear();
            RockControlHelper.CreateChildControls(this, Controls);

            _etpEntityType                       = new EntityTypePicker();
            _etpEntityType.ID                    = this.ID + "_etpEntityType";
            _etpEntityType.Required              = false;
            _etpEntityType.IncludeGlobalOption   = false;
            _etpEntityType.EntityTypes           = new EntityTypeService(new RockContext()).Queryable().Where(a => a.IsEntity == true && a.SingleValueFieldTypeId.HasValue).ToList();
            _etpEntityType.AutoPostBack          = true;
            _etpEntityType.SelectedIndexChanged += _etpEntityType_SelectedIndexChanged;
            Controls.Add(_etpEntityType);

            _phEntityTypeEntityIdValue    = new PlaceHolder();
            _phEntityTypeEntityIdValue.ID = this.ID + "_phEntityTypeEntityIdValue";
            _phEntityTypeEntityIdValue.EnableViewState = false;
            Controls.Add(_phEntityTypeEntityIdValue);

            // figure out which picker to render based on the EntityType
            UpdateEntityTypeControls();
        }
示例#3
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Controls.Clear();
            RockControlHelper.CreateChildControls( this, Controls );

            _etpEntityType = new EntityTypePicker();
            _etpEntityType.ID = this.ID + "_etpEntityType";
            _etpEntityType.Required = false;
            _etpEntityType.IncludeGlobalOption = false;
            _etpEntityType.EntityTypes = new EntityTypeService( new RockContext() ).Queryable().Where( a => a.IsEntity == true && a.SingleValueFieldTypeId.HasValue ).ToList();
            _etpEntityType.AutoPostBack = true;
            _etpEntityType.SelectedIndexChanged += _etpEntityType_SelectedIndexChanged;
            Controls.Add( _etpEntityType );

            _phEntityTypeEntityIdValue = new PlaceHolder();
            _phEntityTypeEntityIdValue.ID = this.ID + "_phEntityTypeEntityIdValue";
            _phEntityTypeEntityIdValue.EnableViewState = false;
            Controls.Add( _phEntityTypeEntityIdValue );

            // figure out which picker to render based on the EntityType
            UpdateEntityTypeControls();
        }
示例#4
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl( Dictionary<string, ConfigurationValue> configurationValues, string id )
        {
            var entityTypePicker = new EntityTypePicker { ID = id };
            entityTypePicker.IncludeGlobalOption = true;

            if ( configurationValues != null )
            {
                bool includeGlobal = false;
                if ( configurationValues.ContainsKey( "includeglobal" ) &&
                    bool.TryParse(configurationValues["includeglobal"].Value, out includeGlobal) &&
                    !includeGlobal)
                {
                    entityTypePicker.IncludeGlobalOption = false;
                }
            }

            entityTypePicker.EntityTypes = new EntityTypeService( new RockContext() ).GetEntities().ToList();
            return entityTypePicker;
        }