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