/// <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> /// 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> /// 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 }); }
/// <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}; }