예제 #1
0
        /// <summary>
        /// Creates the child controls.
        /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterControl"></param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl, FilterMode filterMode)
        {
            var containerControl = new DynamicControlsPanel();

            containerControl.ID       = string.Format("{0}_containerControl", filterControl.ID);
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add(containerControl);

            GroupTypePicker groupTypePicker = new GroupTypePicker();

            groupTypePicker.ID    = filterControl.ID + "_groupTypePicker";
            groupTypePicker.Label = "Group Type";
            groupTypePicker.AddCssClass("js-group-type-picker");
            groupTypePicker.GroupTypes            = new GroupTypeService(new RockContext()).Queryable().ToList();
            groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
            groupTypePicker.AutoPostBack          = true;
            if (filterMode == FilterMode.SimpleFilter)
            {
                // we still need to render the control in order to get the selected GroupTypeId on postback, so just hide it instead
                groupTypePicker.Style[HtmlTextWriterStyle.Display] = "none";
            }

            containerControl.Controls.Add(groupTypePicker);

            // set the GroupTypePicker selected value now so we can create the other controls the depending on know the groupTypeid
            if (filterControl.Page.IsPostBack)
            {
                // since we just created the GroupTypePicker, we'll have to sniff the GroupTypeId from Request.Params
                int?groupTypeId = filterControl.Page.Request.Params[groupTypePicker.UniqueID].AsIntegerOrNull();
                groupTypePicker.SelectedGroupTypeId = groupTypeId;
                EnsureSelectedGroupTypeControls(groupTypePicker);
            }

            return(new Control[] { containerControl });
        }
예제 #2
0
        /// <summary>
        /// Creates the child controls.
        /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterControl"></param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl, FilterMode filterMode)
        {
            var containerControl = new DynamicControlsPanel();

            containerControl.ID       = string.Format("{0}_containerControl", filterControl.ID);
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add(containerControl);

            GroupTypePicker groupTypePicker = new GroupTypePicker();

            groupTypePicker.ID                    = filterControl.ID + "_groupTypePicker";
            groupTypePicker.Label                 = "Group Type";
            groupTypePicker.GroupTypes            = new GroupTypeService(new RockContext()).Queryable().OrderBy(a => a.Order).ThenBy(a => a.Name).ToList();
            groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
            groupTypePicker.AutoPostBack          = true;
            groupTypePicker.Visible               = filterMode == FilterMode.AdvancedFilter;
            containerControl.Controls.Add(groupTypePicker);

            // set the GroupTypePicker selected value now so we can create the other controls the depending on know the groupTypeid
            int?groupTypeId = filterControl.Page.Request.Params[groupTypePicker.UniqueID].AsIntegerOrNull();

            groupTypePicker.SelectedGroupTypeId = groupTypeId;
            groupTypePicker_SelectedIndexChanged(groupTypePicker, new EventArgs());

            return(new Control[] { containerControl });
        }
예제 #3
0
        /// <summary>
        /// Creates the child controls.
        /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterControl"></param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl, FilterMode filterMode)
        {
            var containerControl = new DynamicControlsPanel();

            containerControl.ID       = string.Format("{0}_containerControl", filterControl.ID);
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add(containerControl);

            WorkflowTypePicker workflowTypePicker = new WorkflowTypePicker();

            workflowTypePicker.ID          = filterControl.ID + "_workflowTypePicker";
            workflowTypePicker.Label       = "Workflow Type";
            workflowTypePicker.SelectItem += workflowTypePicker_SelectItem;
            workflowTypePicker.Visible     = filterMode == FilterMode.AdvancedFilter;
            containerControl.Controls.Add(workflowTypePicker);

            // set the WorkflowTypePicker selected value now so we can create the other controls the depending on know the workflowTypeid
            var hfItem         = workflowTypePicker.ControlsOfTypeRecursive <HiddenFieldWithClass>().Where(a => a.CssClass.Contains("js-item-id-value")).FirstOrDefault();
            int?workflowTypeId = filterControl.Page.Request.Params[hfItem.UniqueID].AsIntegerOrNull();

            workflowTypePicker.SetValue(workflowTypeId);
            workflowTypePicker_SelectItem(workflowTypePicker, new EventArgs());

            return(new Control[] { containerControl });
        }
예제 #4
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls(Control parentControl)
        {
            var pnlGroupAttributeFilterControls = new DynamicControlsPanel();

            pnlGroupAttributeFilterControls.ID = parentControl.GetChildControlInstanceName(_CtlGroup);
            parentControl.Controls.Add(pnlGroupAttributeFilterControls);

            pnlGroupAttributeFilterControls.Controls.Clear();

            // Create the field selection dropdown
            var ddlProperty = new RockDropDownList();

            ddlProperty.ID = pnlGroupAttributeFilterControls.GetChildControlInstanceName(_CtlProperty);

            pnlGroupAttributeFilterControls.Controls.Add(ddlProperty);

            // Add empty selection as first item.
            ddlProperty.Items.Add(new ListItem());

            foreach (var entityField in GetGroupMemberAttributes())
            {
                // Add the field to the dropdown of available fields
                ddlProperty.Items.Add(new ListItem(entityField.Title, entityField.Name));
            }

            return(new Control[] { pnlGroupAttributeFilterControls });
        }
        /// <summary>
        /// Handles the ValueChanged event of the workflowTypePicker control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        public void workflowTypePicker_ValueChanged(object sender, EventArgs e)
        {
            DynamicControlsPanel containerControl   = (sender as Control).FirstParentControlOfType <DynamicControlsPanel>();
            WorkflowTypePicker   workflowTypePicker = containerControl.ControlsOfTypeRecursive <WorkflowTypePicker>().Where(a => a.CssClass.Contains("js-workflow-type-picker")).FirstOrDefault();

            EnsureSelectedWorkflowTypeControls(workflowTypePicker);
        }
        /// <summary>
        /// Creates the child controls.
        /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterControl"></param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl, FilterMode filterMode)
        {
            var containerControl = new DynamicControlsPanel();

            containerControl.ID       = string.Format("{0}_containerControl", filterControl.ID);
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add(containerControl);

            WorkflowTypePicker workflowTypePicker = new WorkflowTypePicker();

            workflowTypePicker.ID    = filterControl.ID + "_workflowTypePicker";
            workflowTypePicker.Label = "Workflow Type";
            workflowTypePicker.AddCssClass("js-workflow-type-picker");
            workflowTypePicker.ValueChanged += workflowTypePicker_ValueChanged;
            if (filterMode == FilterMode.SimpleFilter)
            {
                // we still need to render the control in order to get the selected WorkflowTypeId on PostBack, so just hide it instead
                workflowTypePicker.Style[HtmlTextWriterStyle.Display] = "none";
            }

            containerControl.Controls.Add(workflowTypePicker);

            // set the WorkflowTypePicker selected value now so we can create the other controls the depending on know the workflowTypeId
            if (filterControl.Page.IsPostBack)
            {
                var hiddenField = workflowTypePicker.ControlsOfTypeRecursive <HiddenFieldWithClass>().Where(a => a.CssClass.Contains("js-item-id-value")).FirstOrDefault();

                // since we just created the WorkflowTypePicker, we'll have to sniff the WorkflowTypeId from Request.Params
                int?workflowTypeId = filterControl.Page.Request.Params[hiddenField.UniqueID].AsIntegerOrNull();
                workflowTypePicker.SetValue(workflowTypeId);
                EnsureSelectedWorkflowTypeControls(workflowTypePicker);
            }

            return(new Control[] { containerControl });
        }
예제 #7
0
        /// <summary>
        /// Creates the child controls.
        /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterControl"></param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl, FilterMode filterMode)
        {
            var containerControl = new DynamicControlsPanel();

            containerControl.ID       = string.Format("{0}_containerControl", filterControl.ID);
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add(containerControl);

            RockDropDownList contentChannelTypePicker = new RockDropDownList();

            contentChannelTypePicker.ID    = filterControl.ID + "_contentChannelTypePicker";
            contentChannelTypePicker.Label = "Content Channel Type";

            contentChannelTypePicker.Items.Clear();
            var contentChannelTypeList = new ContentChannelTypeService(new RockContext()).Queryable().OrderBy(a => a.Name).ToList();

            foreach (var contentChannelType in contentChannelTypeList)
            {
                contentChannelTypePicker.Items.Add(new ListItem(contentChannelType.Name, contentChannelType.Id.ToString()));
            }

            contentChannelTypePicker.SelectedIndexChanged += contentChannelTypePicker_SelectedIndexChanged;
            contentChannelTypePicker.AutoPostBack          = true;
            contentChannelTypePicker.Visible = filterMode == FilterMode.AdvancedFilter;
            containerControl.Controls.Add(contentChannelTypePicker);

            // set the contentChannelTypePicker selected value now so we can create the other controls that depend on knowing the contentChannelTypeId
            int?contentChannelTypeId = filterControl.Page.Request.Params[contentChannelTypePicker.UniqueID].AsIntegerOrNull();

            contentChannelTypePicker.SelectedValue = contentChannelTypeId.ToString();
            contentChannelTypePicker_SelectedIndexChanged(contentChannelTypePicker, new EventArgs());

            return(new Control[] { containerControl });
        }
예제 #8
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the contentChannelTypePicker control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        public void contentChannelTypePicker_SelectedIndexChanged(object sender, EventArgs e)
        {
            RockDropDownList     contentChannelTypePicker = sender as RockDropDownList;
            DynamicControlsPanel containerControl         = contentChannelTypePicker.Parent as DynamicControlsPanel;
            FilterField          filterControl            = containerControl.FirstParentControlOfType <FilterField>();

            containerControl.Controls.Clear();
            containerControl.Controls.Add(contentChannelTypePicker);

            // Create the field selection dropdown
            var ddlProperty = new RockDropDownList();

            ddlProperty.ID = string.Format("{0}_{1}_ddlProperty", containerControl.ID, contentChannelTypePicker.SelectedValue.AsInteger());
            ddlProperty.Attributes["EntityTypeId"] = EntityTypeCache.GetId <Rock.Model.ContentChannelItem>().ToString();
            containerControl.Controls.Add(ddlProperty);

            // add Empty option first
            ddlProperty.Items.Add(new ListItem());

            var entityFields = GetContentChannelItemAttributes(contentChannelTypePicker.SelectedValue.AsIntegerOrNull());

            foreach (var entityField in entityFields)
            {
                string controlId = string.Format("{0}_{1}", containerControl.ID, entityField.UniqueName);
                var    control   = entityField.FieldType.Field.FilterControl(entityField.FieldConfig, controlId, true, filterControl.FilterMode);
                if (control != null)
                {
                    // Add the field to the dropdown of available fields
                    if (AttributeCache.Get(entityField.AttributeGuid.Value)?.EntityTypeQualifierColumn == "ContentChannelTypeId")
                    {
                        ddlProperty.Items.Add(new ListItem(entityField.TitleWithoutQualifier, entityField.UniqueName));
                    }
                    else
                    {
                        ddlProperty.Items.Add(new ListItem(entityField.Title, entityField.UniqueName));
                    }

                    containerControl.Controls.Add(control);
                }
            }

            ddlProperty.AutoPostBack = true;

            // grab the currently selected value off of the request params since we are creating the controls after the Page Init
            var selectedValue = ddlProperty.Page.Request.Params[ddlProperty.UniqueID];

            if (selectedValue != null)
            {
                ddlProperty.SelectedValue = selectedValue;
                ddlProperty_SelectedIndexChanged(ddlProperty, new EventArgs());
            }

            ddlProperty.SelectedIndexChanged += ddlProperty_SelectedIndexChanged;
        }
예제 #9
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl, FilterMode filterMode)
        {
            var containerControl = new DynamicControlsPanel();

            containerControl.ID       = string.Format("{0}_containerControl", filterControl.ID);
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add(containerControl);

            // Create the field selection dropdown
            var ddlEntityField = new RockDropDownList();

            ddlEntityField.ID           = string.Format("{0}_ddlProperty", filterControl.ID);
            ddlEntityField.ClientIDMode = ClientIDMode.Predictable;
            containerControl.Controls.Add(ddlEntityField);

            // add Empty option first
            ddlEntityField.Items.Add(new ListItem());
            var rockBlock = filterControl.RockBlock();

            this.entityFields = EntityHelper.GetEntityFields(entityType);
            foreach (var entityField in this.entityFields)
            {
                bool isAuthorized = true;
                if (entityField.FieldKind == FieldKind.Attribute && entityField.AttributeGuid.HasValue)
                {
                    var attribute = AttributeCache.Read(entityField.AttributeGuid.Value);
                    if (attribute != null && rockBlock != null)
                    {
                        // only show the Attribute field in the drop down if they have VIEW Auth to it
                        isAuthorized = attribute.IsAuthorized(Rock.Security.Authorization.VIEW, rockBlock.CurrentPerson);
                    }
                }

                if (isAuthorized)
                {
                    ddlEntityField.Items.Add(new ListItem(entityField.Title, entityField.Name));
                }
            }

            ddlEntityField.AutoPostBack = true;

            // grab the currently selected value off of the request params since we are creating the controls after the Page Init
            var selectedValue = ddlEntityField.Page.Request.Params[ddlEntityField.UniqueID];

            if (selectedValue != null)
            {
                ddlEntityField.SelectedValue = selectedValue;
                ddlEntityField_SelectedIndexChanged(ddlEntityField, new EventArgs());
            }

            ddlEntityField.SelectedIndexChanged += ddlEntityField_SelectedIndexChanged;

            return(new Control[] { containerControl });
        }
예제 #10
0
        /// <summary>
        /// Ensures that the correct attribute filter controls are created based on the selected <see cref="StepType"/>.
        /// </summary>
        /// <param name="stepTypePicker">The <see cref="StepTypePicker"/>.</param>
        private void EnsureSelectedStepTypeControls(StepTypePicker stepTypePicker)
        {
            DynamicControlsPanel containerControl = stepTypePicker.Parent as DynamicControlsPanel;
            FilterField          filterControl    = containerControl.FirstParentControlOfType <FilterField>();

            // Get the EntityFields for the attributes associated with the selected StepType.
            var entityFields = GetStepAttributes(stepTypePicker.SelectedValueAsId());

            // Create the attribute selection dropdown.
            string           propertyControlId = string.Format("{0}_ddlProperty", containerControl.ID);
            RockDropDownList ddlProperty       = containerControl.Controls.OfType <RockDropDownList>().FirstOrDefault(a => a.ID == propertyControlId);

            if (ddlProperty == null)
            {
                ddlProperty                       = new RockDropDownList();
                ddlProperty.ID                    = propertyControlId;
                ddlProperty.AutoPostBack          = true;
                ddlProperty.SelectedIndexChanged += ddlProperty_SelectedIndexChanged;
                ddlProperty.AddCssClass("js-property-dropdown");
                containerControl.Controls.Add(ddlProperty);
            }

            // Clear the list of items.  We will rebuild them to match the selected StepType.
            ddlProperty.Items.Clear();

            // Add an empty option.
            ddlProperty.Items.Add(new ListItem());

            // Add a ListItem for each of the attributes.
            foreach (var entityField in entityFields)
            {
                ddlProperty.Items.Add(new ListItem(entityField.TitleWithoutQualifier, entityField.UniqueName));
            }

            if (stepTypePicker.Page.IsPostBack)
            {
                // If the attribute has been selected, make sure that value is retained.
                ddlProperty.SetValue(stepTypePicker.Page.Request.Params[ddlProperty.UniqueID]);
            }

            // Add the filter controls (comparison type and value).
            foreach (var entityField in entityFields)
            {
                string controlId = string.Format("{0}_{1}", containerControl.ID, entityField.UniqueName);
                if (!containerControl.Controls.OfType <Control>().Any(a => a.ID == controlId))
                {
                    var control = entityField.FieldType.Field.FilterControl(entityField.FieldConfig, controlId, true, filterControl.FilterMode);
                    if (control != null)
                    {
                        containerControl.Controls.Add(control);
                    }
                }
            }
        }
예제 #11
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls(Control parentControl)
        {
            var pnlGroupAttributeFilterControls = new DynamicControlsPanel();

            pnlGroupAttributeFilterControls.ID = parentControl.GetChildControlInstanceName(_CtlGroup);
            parentControl.Controls.Add(pnlGroupAttributeFilterControls);

            pnlGroupAttributeFilterControls.Controls.Clear();

            // Create the field selection dropdown
            var ddlProperty = new RockDropDownList();

            ddlProperty.ID = pnlGroupAttributeFilterControls.GetChildControlInstanceName(_CtlProperty);

            pnlGroupAttributeFilterControls.Controls.Add(ddlProperty);

            // Add empty selection as first item.
            ddlProperty.Items.Add(new ListItem());

            var rockBlock = parentControl.RockBlock();

            foreach (var entityField in GetGroupMemberAttributeEntityFields())
            {
                bool includeField = true;
                bool isAuthorized = true;

                if (entityField.FieldKind == FieldKind.Attribute)
                {
                    var attribute = AttributeCache.Get(entityField.AttributeGuid.Value);

                    // Don't include the attribute if it isn't active
                    if (attribute.IsActive == false)
                    {
                        includeField = false;
                    }

                    if (includeField && attribute != null && rockBlock != null)
                    {
                        // only show the Attribute field in the drop down if they have VIEW Auth to it
                        isAuthorized = attribute.IsAuthorized(Rock.Security.Authorization.VIEW, rockBlock.CurrentPerson);
                    }
                }

                if (isAuthorized && includeField)
                {
                    // Add the field to the dropdown of available fields
                    ddlProperty.Items.Add(new ListItem(entityField.Title, entityField.UniqueName));
                }
            }

            return(new Control[] { pnlGroupAttributeFilterControls });
        }
        /// <summary>
        /// Ensures that the controls that are created based on the WorkflowType have been created
        /// </summary>
        /// <param name="workflowTypePicker">The workflow type picker.</param>
        private void EnsureSelectedWorkflowTypeControls(WorkflowTypePicker workflowTypePicker)
        {
            DynamicControlsPanel containerControl = workflowTypePicker.Parent as DynamicControlsPanel;
            FilterField          filterControl    = containerControl.FirstParentControlOfType <FilterField>();

            var entityFields = GetWorkflowAttributes(workflowTypePicker.SelectedValueAsId());

            // Create the field selection dropdown
            string           propertyControlId = string.Format("{0}_ddlProperty", containerControl.ID);
            RockDropDownList ddlProperty       = containerControl.Controls.OfType <RockDropDownList>().FirstOrDefault(a => a.ID == propertyControlId);

            if (ddlProperty == null)
            {
                ddlProperty                       = new RockDropDownList();
                ddlProperty.ID                    = propertyControlId;
                ddlProperty.AutoPostBack          = true;
                ddlProperty.SelectedIndexChanged += ddlProperty_SelectedIndexChanged;
                ddlProperty.AddCssClass("js-property-dropdown");
                ddlProperty.Attributes["EntityTypeId"] = EntityTypeCache.GetId <Rock.Model.Workflow>().ToString();
                containerControl.Controls.Add(ddlProperty);
            }

            // update the list of items just in case the WorkflowType changed
            ddlProperty.Items.Clear();

            // add Empty option first
            ddlProperty.Items.Add(new ListItem());
            foreach (var entityField in entityFields)
            {
                // Add the field to the dropdown of available fields
                ddlProperty.Items.Add(new ListItem(entityField.TitleWithoutQualifier, entityField.UniqueName));
            }

            if (workflowTypePicker.Page.IsPostBack)
            {
                ddlProperty.SetValue(workflowTypePicker.Page.Request.Params[ddlProperty.UniqueID]);
            }

            foreach (var entityField in entityFields)
            {
                string controlId = string.Format("{0}_{1}", containerControl.ID, entityField.UniqueName);
                if (!containerControl.Controls.OfType <Control>().Any(a => a.ID == controlId))
                {
                    var control = entityField.FieldType.Field.FilterControl(entityField.FieldConfig, controlId, true, filterControl.FilterMode);
                    if (control != null)
                    {
                        containerControl.Controls.Add(control);
                    }
                }
            }
        }
예제 #13
0
        /// <summary>
        /// Handles the SelectItem event of the workflowTypePicker control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        public void workflowTypePicker_SelectItem(object sender, EventArgs e)
        {
            WorkflowTypePicker workflowTypePicker = sender as WorkflowTypePicker;

            if (workflowTypePicker == null)
            {
                workflowTypePicker = (sender as Control).FirstParentControlOfType <WorkflowTypePicker>();
            }

            DynamicControlsPanel containerControl = workflowTypePicker.Parent as DynamicControlsPanel;
            FilterField          filterControl    = containerControl.FirstParentControlOfType <FilterField>();

            containerControl.Controls.Clear();
            containerControl.Controls.Add(workflowTypePicker);

            // Create the field selection dropdown
            var ddlProperty = new RockDropDownList();

            ddlProperty.ID = string.Format("{0}_{1}_ddlProperty", containerControl.ID, workflowTypePicker.SelectedValue);
            containerControl.Controls.Add(ddlProperty);

            // add Empty option first
            ddlProperty.Items.Add(new ListItem());

            var entityFields = GetWorkflowAttributes(workflowTypePicker.SelectedValue.AsIntegerOrNull());

            foreach (var entityField in entityFields)
            {
                string controlId = string.Format("{0}_{1}", containerControl.ID, entityField.UniqueName);
                var    control   = entityField.FieldType.Field.FilterControl(entityField.FieldConfig, controlId, true, filterControl.FilterMode);
                if (control != null)
                {
                    // Add the field to the dropdown of available fields
                    ddlProperty.Items.Add(new ListItem(entityField.TitleWithoutQualifier, entityField.UniqueName));
                    containerControl.Controls.Add(control);
                }
            }

            ddlProperty.AutoPostBack = true;

            // grab the currently selected value off of the request params since we are creating the controls after the Page Init
            var selectedValue = ddlProperty.Page.Request.Params[ddlProperty.UniqueID];

            if (selectedValue != null)
            {
                ddlProperty.SelectedValue = selectedValue;
                ddlProperty_SelectedIndexChanged(ddlProperty, new EventArgs());
            }

            ddlProperty.SelectedIndexChanged += ddlProperty_SelectedIndexChanged;
        }
        /// <summary>
        /// Creates the model representation of the child controls used to display and edit the filter settings.
        /// Implement this version of CreateChildControls if your DataFilterComponent works the same in all filter modes
        /// </summary>
        /// <param name="entityType">The System Type of the entity to which the filter will be applied.</param>
        /// <param name="filterControl">The control that serves as the container for the filter controls.</param>
        /// <returns>
        /// The array of new controls created to implement the filter.
        /// </returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            var pnlGroupAttributeFilterControls = new DynamicControlsPanel();

            pnlGroupAttributeFilterControls.ID       = filterControl.GetChildControlInstanceName(_CtlGroup);
            pnlGroupAttributeFilterControls.CssClass = "js-container-control";
            filterControl.Controls.Add(pnlGroupAttributeFilterControls);

            pnlGroupAttributeFilterControls.Controls.Clear();

            // Create the field selection dropdown
            var ddlProperty = new RockDropDownList();

            ddlProperty.ID = pnlGroupAttributeFilterControls.GetChildControlInstanceName(_CtlProperty);

            pnlGroupAttributeFilterControls.Controls.Add(ddlProperty);

            // Add empty selection as first item.
            ddlProperty.Items.Add(new ListItem());

            foreach (var entityField in GetGroupMemberAttributes())
            {
                string controlId = pnlGroupAttributeFilterControls.GetChildControlInstanceName(entityField.Name);
                var    control   = entityField.FieldType.Field.FilterControl(entityField.FieldConfig, controlId, true, filterControl.FilterMode);
                if (control != null)
                {
                    // Add the field to the dropdown of available fields
                    ddlProperty.Items.Add(new ListItem(entityField.Title, entityField.Name));
                    pnlGroupAttributeFilterControls.Controls.Add(control);
                }
            }

            ddlProperty.AutoPostBack = true;

            return(new Control[] { pnlGroupAttributeFilterControls });
        }
예제 #15
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls( Type entityType, FilterField filterControl, FilterMode filterMode )
        {
            var containerControl = new DynamicControlsPanel();
            containerControl.ID = string.Format( "{0}_containerControl", filterControl.ID );
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add( containerControl );

            // Create the field selection dropdown
            var ddlEntityField = new RockDropDownList();
            ddlEntityField.ID = string.Format( "{0}_ddlProperty", filterControl.ID );
            ddlEntityField.ClientIDMode = ClientIDMode.Predictable;
            containerControl.Controls.Add( ddlEntityField );

            // add Empty option first
            ddlEntityField.Items.Add( new ListItem() );
            var rockBlock = filterControl.RockBlock();
            var entityTypeCache = EntityTypeCache.Read( entityType, true );

            this.entityFields = EntityHelper.GetEntityFields( entityType );
            foreach ( var entityField in this.entityFields.OrderBy(a => !a.IsPreviewable).ThenBy(a => a.FieldKind != FieldKind.Property ).ThenBy(a => a.Title) )
            {
                bool isAuthorized = true;
                bool includeField = true;
                if ( entityField.FieldKind == FieldKind.Attribute && entityField.AttributeGuid.HasValue)
                {
                    if ( entityType == typeof( Rock.Model.Workflow ) && !string.IsNullOrWhiteSpace(entityField.AttributeEntityTypeQualifierName) )
                    {
                        // Workflows can contain tons of Qualified Attributes, so let the WorkflowAttributeFilter take care of those
                        includeField = false;
                    }

                    var attribute = AttributeCache.Read( entityField.AttributeGuid.Value );
                    if ( includeField && attribute != null && rockBlock != null )
                    {
                        // only show the Attribute field in the drop down if they have VIEW Auth to it
                        isAuthorized = attribute.IsAuthorized( Rock.Security.Authorization.VIEW, rockBlock.CurrentPerson );
                    }
                }

                if ( isAuthorized && includeField )
                {
                    var listItem = new ListItem( entityField.Title, entityField.Name );

                    if ( entityField.IsPreviewable )
                    {
                        listItem.Attributes["optiongroup"] = "Common";
                    }
                    else if (entityField.FieldKind == FieldKind.Attribute)
                    {
                        listItem.Attributes["optiongroup"] = string.Format( "{0} Attributes", entityType.Name );
                    }
                    else
                    {
                        listItem.Attributes["optiongroup"] = string.Format( "{0} Fields", entityType.Name );
                    }

                    ddlEntityField.Items.Add( listItem  );
                }
            }

            ddlEntityField.AutoPostBack = true;

            // grab the currently selected value off of the request params since we are creating the controls after the Page Init
            var selectedValue = ddlEntityField.Page.Request.Params[ddlEntityField.UniqueID];
            if ( selectedValue != null )
            {
                ddlEntityField.SelectedValue = selectedValue;
                ddlEntityField_SelectedIndexChanged( ddlEntityField, new EventArgs() );
            }

            ddlEntityField.SelectedIndexChanged += ddlEntityField_SelectedIndexChanged;

            return new Control[] { containerControl };
        }
        /// <summary>
        /// Creates the child controls.
        /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterControl"></param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls( Type entityType, FilterField filterControl, FilterMode filterMode )
        {
            var containerControl = new DynamicControlsPanel();
            containerControl.ID = string.Format( "{0}_containerControl", filterControl.ID );
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add( containerControl );

            RockDropDownList contentChannelTypePicker = new RockDropDownList();
            contentChannelTypePicker.ID = filterControl.ID + "_contentChannelTypePicker";
            contentChannelTypePicker.Label = "Content Channel Type";

            contentChannelTypePicker.Items.Clear();
            var contentChannelTypeList = new ContentChannelTypeService( new RockContext() ).Queryable().OrderBy( a => a.Name ).ToList();
            foreach ( var contentChannelType in contentChannelTypeList )
            {
                contentChannelTypePicker.Items.Add( new ListItem( contentChannelType.Name, contentChannelType.Id.ToString() ) );
            }

            contentChannelTypePicker.SelectedIndexChanged += contentChannelTypePicker_SelectedIndexChanged;
            contentChannelTypePicker.AutoPostBack = true;
            contentChannelTypePicker.Visible = filterMode == FilterMode.AdvancedFilter;
            containerControl.Controls.Add( contentChannelTypePicker );

            // set the contentChannelTypePicker selected value now so we can create the other controls that depend on knowing the contentChannelTypeId
            int? contentChannelTypeId = filterControl.Page.Request.Params[contentChannelTypePicker.UniqueID].AsIntegerOrNull();
            contentChannelTypePicker.SelectedValue = contentChannelTypeId.ToString();
            contentChannelTypePicker_SelectedIndexChanged( contentChannelTypePicker, new EventArgs() );

            return new Control[] { containerControl };
        }
예제 #17
0
        /// <summary>
        /// Creates the child controls.
        /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterControl"></param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls( Type entityType, FilterField filterControl, FilterMode filterMode )
        {
            var containerControl = new DynamicControlsPanel();
            containerControl.ID = string.Format( "{0}_containerControl", filterControl.ID );
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add( containerControl );

            WorkflowTypePicker workflowTypePicker = new WorkflowTypePicker();
            workflowTypePicker.ID = filterControl.ID + "_workflowTypePicker";
            workflowTypePicker.Label = "Workflow Type";
            workflowTypePicker.SelectItem += workflowTypePicker_SelectItem;
            workflowTypePicker.Visible = filterMode == FilterMode.AdvancedFilter;
            containerControl.Controls.Add( workflowTypePicker );

            // set the WorkflowTypePicker selected value now so we can create the other controls the depending on know the workflowTypeid
            var hfItem = workflowTypePicker.ControlsOfTypeRecursive<HiddenFieldWithClass>().Where( a => a.CssClass.Contains( "js-item-id-value" ) ).FirstOrDefault();
            int? workflowTypeId = filterControl.Page.Request.Params[hfItem.UniqueID].AsIntegerOrNull();
            workflowTypePicker.SetValue( workflowTypeId );
            workflowTypePicker_SelectItem( workflowTypePicker, new EventArgs() );

            return new Control[] { containerControl };
        }
        /// <summary>
        /// Creates the model representation of the child controls used to display and edit the filter settings.
        /// Implement this version of CreateChildControls if your DataFilterComponent works the same in all filter modes
        /// </summary>
        /// <param name="entityType">The System Type of the entity to which the filter will be applied.</param>
        /// <param name="filterControl">The control that serves as the container for the filter controls.</param>
        /// <returns>
        /// The array of new controls created to implement the filter.
        /// </returns>
        public override Control[] CreateChildControls( Type entityType, FilterField filterControl )
        {
            var pnlGroupAttributeFilterControls = new DynamicControlsPanel();
            pnlGroupAttributeFilterControls.ID = filterControl.GetChildControlInstanceName( _CtlGroup );
            pnlGroupAttributeFilterControls.CssClass = "js-container-control";
            filterControl.Controls.Add( pnlGroupAttributeFilterControls );

            pnlGroupAttributeFilterControls.Controls.Clear();

            // Create the field selection dropdown
            var ddlProperty = new RockDropDownList();
            ddlProperty.ID = pnlGroupAttributeFilterControls.GetChildControlInstanceName( _CtlProperty );

            pnlGroupAttributeFilterControls.Controls.Add( ddlProperty );

            // Add empty selection as first item.
            ddlProperty.Items.Add( new ListItem() );

            foreach (var entityField in GetGroupMemberAttributes())
            {
                string controlId = pnlGroupAttributeFilterControls.GetChildControlInstanceName( entityField.Name );
                var control = entityField.FieldType.Field.FilterControl( entityField.FieldConfig, controlId, true, filterControl.FilterMode );
                if (control != null)
                {
                    // Add the field to the dropdown of available fields
                    ddlProperty.Items.Add( new ListItem( entityField.Title, entityField.Name ) );
                    pnlGroupAttributeFilterControls.Controls.Add( control );
                }
            }

            ddlProperty.AutoPostBack = true;

            return new Control[] {pnlGroupAttributeFilterControls};
        }
예제 #19
0
        /// <summary>
        /// Creates the child controls.
        /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterControl"></param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls( Type entityType, FilterField filterControl, FilterMode filterMode )
        {
            var containerControl = new DynamicControlsPanel();
            containerControl.ID = string.Format( "{0}_containerControl", filterControl.ID );
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add( containerControl );

            GroupTypePicker groupTypePicker = new GroupTypePicker();
            groupTypePicker.ID = filterControl.ID + "_groupTypePicker";
            groupTypePicker.Label = "Group Type";
            groupTypePicker.GroupTypes = new GroupTypeService( new RockContext() ).Queryable().OrderBy( a => a.Order ).ThenBy( a => a.Name ).ToList();
            groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
            groupTypePicker.AutoPostBack = true;
            groupTypePicker.Visible = filterMode == FilterMode.AdvancedFilter;
            containerControl.Controls.Add( groupTypePicker );

            // set the GroupTypePicker selected value now so we can create the other controls the depending on know the groupTypeid
            int? groupTypeId = filterControl.Page.Request.Params[groupTypePicker.UniqueID].AsIntegerOrNull();
            groupTypePicker.SelectedGroupTypeId = groupTypeId;
            groupTypePicker_SelectedIndexChanged( groupTypePicker, new EventArgs() );

            return new Control[] { containerControl };
        }
예제 #20
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls( Type entityType, FilterField filterControl, FilterMode filterMode )
        {
            var containerControl = new DynamicControlsPanel();
            containerControl.ID = string.Format( "{0}_containerControl", filterControl.ID );
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add( containerControl );

            // Create the field selection dropdown
            var ddlEntityField = new RockDropDownList();
            ddlEntityField.ID = string.Format( "{0}_ddlProperty", filterControl.ID );
            ddlEntityField.ClientIDMode = ClientIDMode.Predictable;
            containerControl.Controls.Add( ddlEntityField );

            // add Empty option first
            ddlEntityField.Items.Add( new ListItem() );

            this.entityFields = EntityHelper.GetEntityFields( entityType );
            foreach ( var entityField in this.entityFields )
            {
                ddlEntityField.Items.Add( new ListItem( entityField.Title, entityField.Name ) );
            }

            ddlEntityField.AutoPostBack = true;

            // grab the currently selected value off of the request params since we are creating the controls after the Page Init
            var selectedValue = ddlEntityField.Page.Request.Params[ddlEntityField.UniqueID];
            if ( selectedValue != null )
            {
                ddlEntityField.SelectedValue = selectedValue;
                ddlEntityField_SelectedIndexChanged( ddlEntityField, new EventArgs() );
            }

            ddlEntityField.SelectedIndexChanged += ddlEntityField_SelectedIndexChanged;

            return new Control[] { containerControl };
        }
예제 #21
0
        /// <summary>
        /// Creates the child controls.
        /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterControl"></param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl, FilterMode filterMode)
        {
            // Create a container to hold our dynamic controls and add it to the FilterField.
            var containerControl = new DynamicControlsPanel
            {
                ID       = string.Format("{0}_containerControl", filterControl.ID),
                CssClass = "js-container-control"
            };

            filterControl.Controls.Add(containerControl);

            // Create the StepProgramPicker.
            StepProgramPicker stepProgramPicker = new StepProgramPicker
            {
                ID       = filterControl.ID + "_stepProgramPicker",
                Label    = "Step Program",
                Required = true
            };

            stepProgramPicker.SelectedIndexChanged += stepProgramPicker_SelectedIndexChanged;
            stepProgramPicker.AutoPostBack          = true;
            StepProgramPicker.LoadDropDownItems(stepProgramPicker, true);
            containerControl.Controls.Add(stepProgramPicker);

            // Create the StepTypePicker.
            StepTypePicker stepTypePicker = new StepTypePicker
            {
                ID       = filterControl.ID + "_stepTypePicker",
                CssClass = "js-step-type-picker",
                Label    = "Step Type",
                Required = true
            };

            stepTypePicker.SelectedIndexChanged += stepTypePicker_SelectedIndexChanged;
            stepTypePicker.AutoPostBack          = true;
            containerControl.Controls.Add(stepTypePicker);

            if (filterMode == FilterMode.SimpleFilter)
            {
                // we still need to render the control in order to get the selected StepProgramId on postback, so just hide it instead
                stepProgramPicker.Style[HtmlTextWriterStyle.Display] = "none";
                stepTypePicker.Style[HtmlTextWriterStyle.Display]    = "none";
            }

            if (filterControl.Page.IsPostBack)
            {
                // If the Step Program has already been selected, make sure it retains that value, and
                // set the StepProgramId of the StepTypePicker.
                var stepProgramId = filterControl.Page.Request.Params[stepProgramPicker.UniqueID];
                stepProgramPicker.SelectedValue = stepProgramId;
                stepTypePicker.StepProgramId    = stepProgramId.AsIntegerOrNull();

                // If the Step Type has already been selected, make sure it retains that value.
                var stepTypePickerId = filterControl.Page.Request.Params[stepTypePicker.UniqueID];
                stepTypePicker.SelectedValue = stepTypePickerId;

                // Ensure that the attribute filter controls are updated to reflect the current
                // Step Type selection.
                EnsureSelectedStepTypeControls(stepTypePicker);
            }

            return(new Control[] { containerControl });
        }
예제 #22
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl, FilterMode filterMode)
        {
            var containerControl = new DynamicControlsPanel();

            containerControl.ID       = string.Format("{0}_containerControl", filterControl.ID);
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add(containerControl);

            // Create the field selection dropdown
            var ddlEntityField = new RockDropDownList();

            ddlEntityField.ID           = string.Format("{0}_ddlProperty", filterControl.ID);
            ddlEntityField.ClientIDMode = ClientIDMode.Predictable;

            var entityTypeCache = EntityTypeCache.Get(entityType, true);

            ddlEntityField.Attributes["EntityTypeId"] = entityTypeCache?.Id.ToString();

            containerControl.Controls.Add(ddlEntityField);

            // add Empty option first
            ddlEntityField.Items.Add(new ListItem());
            var rockBlock = filterControl.RockBlock();


            var entityFields = EntityHelper.GetEntityFields(entityType);

            foreach (var entityField in entityFields.OrderBy(a => !a.IsPreviewable).ThenBy(a => a.FieldKind != FieldKind.Property).ThenBy(a => a.Title))
            {
                bool isAuthorized = true;
                bool includeField = true;
                if (entityField.FieldKind == FieldKind.Attribute && entityField.AttributeGuid.HasValue)
                {
                    if (entityType == typeof(Rock.Model.Workflow) && !string.IsNullOrWhiteSpace(entityField.AttributeEntityTypeQualifierName))
                    {
                        // Workflows can contain tons of Qualified Attributes, so let the WorkflowAttributeFilter take care of those
                        includeField = false;
                    }

                    var attribute = AttributeCache.Get(entityField.AttributeGuid.Value);

                    // Don't include the attribute if it isn't active
                    if (attribute.IsActive == false)
                    {
                        includeField = false;
                    }

                    if (includeField && attribute != null && rockBlock != null)
                    {
                        // only show the Attribute field in the drop down if they have VIEW Auth to it
                        isAuthorized = attribute.IsAuthorized(Rock.Security.Authorization.VIEW, rockBlock.CurrentPerson);
                    }
                }

                if (isAuthorized && includeField)
                {
                    var listItem = new ListItem(entityField.Title, entityField.UniqueName);

                    if (entityField.IsPreviewable)
                    {
                        listItem.Attributes["optiongroup"] = "Common";
                    }
                    else if (entityField.FieldKind == FieldKind.Attribute)
                    {
                        listItem.Attributes["optiongroup"] = string.Format("{0} Attributes", entityType.Name);
                    }
                    else
                    {
                        listItem.Attributes["optiongroup"] = string.Format("{0} Fields", entityType.Name);
                    }

                    ddlEntityField.Items.Add(listItem);
                }
            }

            ddlEntityField.AutoPostBack = true;

            // grab the currently selected value off of the request params since we are creating the controls after the Page Init
            var selectedValue = ddlEntityField.Page.Request.Params[ddlEntityField.UniqueID];

            if (selectedValue != null)
            {
                ddlEntityField.SelectedValue = selectedValue;
                ddlEntityField_SelectedIndexChanged(ddlEntityField, new EventArgs());
            }

            ddlEntityField.SelectedIndexChanged += ddlEntityField_SelectedIndexChanged;

            return(new Control[] { containerControl });
        }
예제 #23
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();

            _phControls = new DynamicPlaceholder {
                ID = "phControls"
            };
            this.Controls.Add(_phControls);

            _pnlRow = new DynamicControlsPanel {
                ID = "pnlRow", CssClass = "row"
            };
            _pnlCol1 = new DynamicControlsPanel {
                ID = "pnlCol1", CssClass = "col-sm-4"
            };
            _pnlCol2 = new DynamicControlsPanel {
                ID = "pnlCol2", CssClass = "col-sm-4"
            };
            _pnlCol3 = new DynamicControlsPanel {
                ID = "pnlCol3", CssClass = "col-sm-4"
            };
            _phControls.Controls.Add(_pnlRow);
            _pnlRow.Controls.Add(_pnlCol1);
            _pnlRow.Controls.Add(_pnlCol2);
            _pnlRow.Controls.Add(_pnlCol3);


            _hfPersonId = new HiddenField
            {
                ID = "_hfPersonId"
            };

            _phControls.Controls.Add(_hfPersonId);

            _dvpPersonTitle = new DefinedValuePicker
            {
                ID              = "_dvpPersonTitle",
                DefinedTypeId   = DefinedTypeCache.GetId(Rock.SystemGuid.DefinedType.PERSON_TITLE.AsGuid()),
                Label           = "Title",
                CssClass        = "input-width-md",
                ValidationGroup = ValidationGroup
            };

            _tbPersonFirstName = new RockTextBox
            {
                ID               = "tbPersonFirstName",
                Label            = "First Name",
                Required         = true,
                AutoCompleteType = AutoCompleteType.None,
                ValidationGroup  = ValidationGroup
            };

            _tbPersonLastName = new RockTextBox
            {
                ID               = "tbPersonLastName",
                Label            = "Last Name",
                Required         = true,
                AutoCompleteType = AutoCompleteType.None,
                ValidationGroup  = ValidationGroup
            };

            _dvpPersonSuffix = new DefinedValuePicker
            {
                ID              = "dvpPersonSuffix",
                DefinedTypeId   = DefinedTypeCache.GetId(Rock.SystemGuid.DefinedType.PERSON_SUFFIX.AsGuid()),
                Label           = "Suffix",
                CssClass        = "input-width-md",
                ValidationGroup = ValidationGroup
            };

            // Have Email and PhoneNumber hidden by default
            _ebPersonEmail = new EmailBox
            {
                ID              = "ebPersonEmail",
                Label           = "Email",
                ValidationGroup = ValidationGroup,
                Visible         = false
            };

            _pnbMobilePhoneNumber = new PhoneNumberBox
            {
                Label   = "Mobile Phone",
                ID      = "pnbMobilePhoneNumber",
                Visible = false
            };

            _dvpPersonConnectionStatus = new DefinedValuePicker
            {
                ID              = "dvpPersonConnectionStatus",
                DefinedTypeId   = DefinedTypeCache.GetId(Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS.AsGuid()),
                Label           = "Connection Status",
                Required        = true,
                ValidationGroup = ValidationGroup
            };

            _rblPersonRole = new RockRadioButtonList
            {
                ID              = "rblPersonRole",
                Label           = "Role",
                RepeatDirection = RepeatDirection.Horizontal,
                DataTextField   = "Name",
                DataValueField  = "Id",
                Required        = true,
                ValidationGroup = ValidationGroup
            };

            _rblPersonGender = new RockRadioButtonList
            {
                ID              = "rblPersonGender",
                Label           = "Gender",
                RepeatDirection = RepeatDirection.Horizontal,
                Required        = this.RequireGender,
                ValidationGroup = this.RequireGender == true ? ValidationGroup : string.Empty,
                ShowNoneOption  = false
            };

            _bdpPersonBirthDate = new BirthdayPicker
            {
                ID              = "bdpPersonBirthDate",
                Label           = "Birthdate",
                ValidationGroup = ValidationGroup
            };

            _ddlGradePicker = new GradePicker
            {
                ID                    = "ddlGradePicker",
                Label                 = "Grade",
                UseAbbreviation       = true,
                UseGradeOffsetAsValue = true,
                ValidationGroup       = ValidationGroup
            };

            _dvpPersonMaritalStatus = new DefinedValuePicker
            {
                ID              = "dvpPersonMaritalStatus",
                Label           = "Marital Status",
                DefinedTypeId   = DefinedTypeCache.GetId(Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS.AsGuid()),
                ValidationGroup = ValidationGroup
            };

            var groupType = GroupTypeCache.GetFamilyGroupType();

            _rblPersonRole.DataSource = groupType.Roles.OrderBy(r => r.Order).ToList();
            _rblPersonRole.DataBind();

            _rblPersonGender.Items.Clear();
            _rblPersonGender.Items.Add(new ListItem(Gender.Male.ConvertToString(), Gender.Male.ConvertToInt().ToString()));
            _rblPersonGender.Items.Add(new ListItem(Gender.Female.ConvertToString(), Gender.Female.ConvertToInt().ToString()));

            ArrangePersonControls(this.ShowInColumns);
            UpdatePersonControlLabels();
        }