Пример #1
0
        /// <summary>
        /// Creates the HTML controls required to configure this type of field
        /// </summary>
        /// <returns></returns>
        public override List <Control> ConfigurationControls()
        {
            var stepProgramPicker = new StepProgramPicker
            {
                Label = "Default Step Program",
                Help  = "The default step program selection"
            };

            StepProgramPicker.LoadDropDownItems(stepProgramPicker, true);
            return(new List <Control> {
                stepProgramPicker
            });
        }
Пример #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)
        {
            // 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 });
        }