/// <summary> /// Sets the selection. /// </summary> /// <param name="entityType"></param> /// <param name="controls">The controls.</param> /// <param name="selection">The selection.</param> public override void SetSelection(Type entityType, Control[] controls, string selection) { if (!string.IsNullOrWhiteSpace(selection)) { var values = JsonConvert.DeserializeObject <List <string> >(selection); if (controls.Length > 0 && values.Count > 0) { var workflowType = new WorkflowTypeService(new RockContext()).Get(values[0].AsGuid()); if (workflowType != null) { var containerControl = controls[0] as DynamicControlsPanel; if (containerControl.Controls.Count > 0) { WorkflowTypePicker workflowTypePicker = containerControl.Controls[0] as WorkflowTypePicker; workflowTypePicker.SetValue(workflowType.Id); workflowTypePicker_SelectItem(workflowTypePicker, new EventArgs()); } if (containerControl.Controls.Count > 1 && values.Count > 1) { DropDownList ddlProperty = containerControl.Controls[1] as DropDownList; var entityFields = GetWorkflowAttributes(workflowType.Id); var panelControls = new List <Control>(); panelControls.AddRange(containerControl.Controls.OfType <Control>()); SetEntityFieldSelection(entityFields, ddlProperty, values.Skip(1).ToList(), panelControls); } } } } }
/// <summary> /// Sets the selection. /// </summary> /// <param name="entityType"></param> /// <param name="controls">The controls.</param> /// <param name="selection">The selection.</param> public override void SetSelection(Type entityType, Control[] controls, string selection) { var settings = SelectionConfig.Parse(selection); if (controls.Length > 0) { int?workflowTypeId = settings.WorkflowTypeId; var containerControl = controls[0] as DynamicControlsPanel; if (containerControl.Controls.Count > 0) { WorkflowTypePicker workflowTypePicker = containerControl.Controls[0] as WorkflowTypePicker; workflowTypePicker.SetValue(workflowTypeId); EnsureSelectedWorkflowTypeControls(workflowTypePicker); } if (containerControl.Controls.Count > 1) { DropDownList ddlProperty = containerControl.Controls[1] as DropDownList; var entityFields = GetWorkflowAttributes(workflowTypeId); var panelControls = new List <Control>(); panelControls.AddRange(containerControl.Controls.OfType <Control>()); var parameters = new List <string> { settings.AttributeKey }; parameters.AddRange(settings.AttributeFilterSettings); SetEntityFieldSelection(entityFields, ddlProperty, parameters, panelControls); } } }
/// <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 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 }); }