/// <summary> /// Sets the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="controls">The controls.</param> /// <param name="selection">The selection.</param> public override void SetSelection(Type entityType, Control[] controls, string selection) { if (controls.Count() < 1) { return; } GroupPicker groupPicker = controls[0] as GroupPicker; List <Guid> groupGuids = selection.Split(',').AsGuidList(); var groups = new GroupService(new RockContext()).GetByGuids(groupGuids); if (groups != null) { groupPicker.SetValues(groups); } }
/// <summary> /// Sets the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="controls">The controls.</param> /// <param name="selection">The selection.</param> public override void SetSelection(Type entityType, Control[] controls, string selection) { if (controls.Count() < 6) { return; } GroupPicker groupPicker = controls[0] as GroupPicker; RockCheckBox cbChildGroups = controls[1] as RockCheckBox; RockCheckBox cbIncludeSelectedGroup = controls[2] as RockCheckBox; RockCheckBox cbChildGroupsPlusDescendants = controls[3] as RockCheckBox; RockCheckBoxList cblRoles = controls[4] as RockCheckBoxList; RockDropDownList ddlGroupMemberStatus = controls[5] as RockDropDownList; RockCheckBox cbIncludeInactive = controls[6] as RockCheckBox; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 2) { List <Guid> groupGuids = selectionValues[0].Split(',').AsGuidList(); var groups = new GroupService(new RockContext()).GetByGuids(groupGuids); if (groups != null) { groupPicker.SetValues(groups); } if (selectionValues.Length >= 3) { cbChildGroups.Checked = selectionValues[2].AsBooleanOrNull() ?? false; } if (selectionValues.Length >= 6) { cbIncludeSelectedGroup.Checked = selectionValues[4].AsBooleanOrNull() ?? false; cbChildGroupsPlusDescendants.Checked = selectionValues[5].AsBooleanOrNull() ?? false; } else { cbIncludeSelectedGroup.Checked = true; cbChildGroupsPlusDescendants.Checked = true; } if (selectionValues.Length >= 7) { cbIncludeInactiveGroups.Checked = selectionValues[6].AsBooleanOrNull() ?? false; } else { // if options where saved before this option was added, set to false, even though it would have included inactive before cbIncludeInactiveGroups.Checked = false; } gp_SelectItem(this, new EventArgs()); string[] selectedRoleGuids = selectionValues[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in cblRoles.Items.OfType <ListItem>()) { item.Selected = selectedRoleGuids.Contains(item.Value); } if (selectionValues.Length >= 4) { ddlGroupMemberStatus.SetValue(selectionValues[3]); } else { ddlGroupMemberStatus.SetValue(string.Empty); } } }