Exemple #1
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            CampusesPicker campusesPicker = new CampusesPicker();

            campusesPicker.ID       = filterControl.ID + "_0";
            campusesPicker.Label    = string.Empty;
            campusesPicker.CssClass = $"{ControlClassName} campuses-picker";
            campusesPicker.Campuses = CampusCache.All(IncludeInactive);

            filterControl.Controls.Add(campusesPicker);

            return(new Control[1] {
                campusesPicker
            });
        }
        /// <summary>
        /// Creates the child controls.
        /// </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 campusesPicker = new CampusesPicker();

            campusesPicker.Label    = "Campuses";
            campusesPicker.ID       = filterControl.ID + "_0";
            campusesPicker.Label    = string.Empty;
            campusesPicker.CssClass = "js-campuses-picker campuses-picker";
            campusesPicker.Campuses = CampusCache.All();
            filterControl.Controls.Add(campusesPicker);

            var ddlIntegerCompare = ComparisonHelper.ComparisonControl(ComparisonHelper.NumericFilterComparisonTypes);

            ddlIntegerCompare.Label = "Attendance Count";
            ddlIntegerCompare.ID    = filterControl.ID + "_ddlIntegerCompare";
            ddlIntegerCompare.AddCssClass("js-filter-compare");
            filterControl.Controls.Add(ddlIntegerCompare);

            var tbAttendedCount = new RockTextBox();

            tbAttendedCount.ID    = filterControl.ID + "_2";
            tbAttendedCount.Label = "&nbsp;"; // give it whitespace label so it lines up nicely
            tbAttendedCount.AddCssClass("js-attended-count");
            filterControl.Controls.Add(tbAttendedCount);

            var slidingDateRangePicker = new SlidingDateRangePicker();

            slidingDateRangePicker.Label = "Date Range";
            slidingDateRangePicker.ID    = filterControl.ID + "_slidingDateRangePicker";
            slidingDateRangePicker.AddCssClass("js-sliding-date-range");
            filterControl.Controls.Add(slidingDateRangePicker);

            var controls = new Control[4] {
                campusesPicker, ddlIntegerCompare, tbAttendedCount, slidingDateRangePicker
            };

            // convert pipe to comma delimited
            var defaultDelimitedValues = slidingDateRangePicker.DelimitedValues.Replace("|", ",");
            var defaultCount           = 4;

            // set the default values in case this is a newly added filter
            SetSelection(
                entityType,
                controls,
                string.Format("{0}|{1}|{2}|{3}|false", campusesPicker.Items.Count > 0 ? campusesPicker.Items[0].Value : "0", ComparisonType.GreaterThanOrEqualTo.ConvertToInt().ToString(), defaultCount, defaultDelimitedValues));

            return(controls);
        }