Esempio n. 1
0
        /// <summary>
        /// Creates a block-level radio button that is part of the group.
        /// </summary>
        /// <param name="isSelected"></param>
        /// <param name="validationMethod">The validation method. Do not pass null.</param>
        /// <param name="label"></param>
        /// <param name="action"></param>
        /// <param name="autoPostBack"></param>
        /// <param name="pageModificationValue"></param>
        /// <param name="nestedControlListGetter"></param>
        /// <returns></returns>
        public BlockCheckBox CreateBlockRadioButton(
            bool isSelected, Action <PostBackValue <bool>, Validator> validationMethod, string label = "", FormAction action = null, bool autoPostBack = false,
            PageModificationValue <bool> pageModificationValue = null, Func <IEnumerable <Control> > nestedControlListGetter = null)
        {
            BlockCheckBox checkBox   = null;
            var           validation =
                formValue.CreateValidation(
                    (postBackValue, validator) => validationMethod(new PostBackValue <bool>(postBackValue.Value == checkBox, postBackValue.ChangedOnPostBack), validator));

            checkBox = new BlockCheckBox(
                formValue,
                label,
                new BlockCheckBoxSetup(action: action, triggersActionWhenCheckedOrUnchecked: autoPostBack, nestedControlListGetter: nestedControlListGetter),
                () =>
                checkBoxesAndSelectionStatesAndPageModificationValues.Where(i => i.Item3 != null)
                .Select(i => i.Item3.GetJsModificationStatements(i.Item1 == checkBox ? "true" : "false")),
                validation);
            checkBoxesAndSelectionStatesAndPageModificationValues.Add(
                Tuple.Create <CommonCheckBox, bool, PageModificationValue <bool> >(checkBox, isSelected, pageModificationValue));

            if (pageModificationValue != null)
            {
                formValue.AddPageModificationValue(pageModificationValue, value => value == checkBox);
            }

            return(checkBox);
        }
Esempio n. 2
0
        void ControlTreeDataLoader.LoadData()
        {
            CssClass = CssClass.ConcatenateWithSpace(CheckBoxListCssElementCreator.CssClass);

            var table = new DynamicTable {
                Caption = caption
            };

            if (includeSelectAndDeselectAllButtons)
            {
                table.AddActionLink(new ActionButtonSetup("Select All", new CustomButton(() => string.Format(@"toggleCheckBoxes( '{0}', true )", ClientID))));
                table.AddActionLink(new ActionButtonSetup("Deselect All", new CustomButton(() => string.Format(@"toggleCheckBoxes( '{0}', false )", ClientID))));
            }

            var itemsPerColumn = (int)Math.Ceiling((decimal)items.Count() / numberOfColumns);
            var cells          = new List <EwfTableCell>();

            for (byte i = 0; i < numberOfColumns; i += 1)
            {
                var maxIndex = Math.Min((i + 1) * itemsPerColumn, items.Count());
                var place    = new PlaceHolder();
                for (var j = i * itemsPerColumn; j < maxIndex; j += 1)
                {
                    var item     = items.ElementAt(j);
                    var checkBox = new BlockCheckBox(selectedItemIds.Contains(item.Id), label: item.Label, highlightWhenChecked: true, postBack: postBack);
                    place.Controls.Add(checkBox);
                    checkBoxesByItem.Add(item, checkBox);
                }
                cells.Add(place);
            }
            table.AddRow(cells.ToArray());
            Controls.Add(table);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a block-level radio button that is part of the group.
        /// </summary>
        public BlockCheckBox CreateBlockRadioButton(bool isSelected, string label = "", PostBack postBack = null, bool autoPostBack = false)
        {
            var checkBox = new BlockCheckBox(formValue, label, postBack)
            {
                AutoPostBack = autoPostBack
            };

            checkBoxesAndSelectionStates.Add(Tuple.Create <CommonCheckBox, bool>(checkBox, isSelected));
            return(checkBox);
        }
        /// <summary>
        /// Creates a check box list.
        /// </summary>
        public EwfCheckBoxList(
            IEnumerable <SelectListItem <ItemIdType> > items, IEnumerable <ItemIdType> selectedItemIds, string caption = "", bool includeSelectAndDeselectAllButtons = false,
            byte numberOfColumns = 1, FormAction action = null)
        {
            this.items      = items.ToArray();
            selectedItemIds = selectedItemIds.ToArray();

            CssClass = CssClass.ConcatenateWithSpace(CheckBoxListCssElementCreator.CssClass);

            var table = new DynamicTable {
                Caption = caption
            };

            if (includeSelectAndDeselectAllButtons)
            {
                table.AddActionLink(new ActionButtonSetup("Select All", new CustomButton(() => string.Format(@"toggleCheckBoxes( '{0}', true )", ClientID))));
                table.AddActionLink(new ActionButtonSetup("Deselect All", new CustomButton(() => string.Format(@"toggleCheckBoxes( '{0}', false )", ClientID))));
            }

            var itemsPerColumn = (int)Math.Ceiling((decimal)this.items.Count() / numberOfColumns);
            var cells          = new List <EwfTableCell>();

            for (byte i = 0; i < numberOfColumns; i += 1)
            {
                var maxIndex = Math.Min((i + 1) * itemsPerColumn, this.items.Count());
                var place    = new PlaceHolder();
                for (var j = i * itemsPerColumn; j < maxIndex; j += 1)
                {
                    var item     = this.items.ElementAt(j);
                    var checkBox = new BlockCheckBox(
                        selectedItemIds.Contains(item.Id),
                        (postBackValue, validator) => { },
                        label: item.Label,
                        setup: new BlockCheckBoxSetup(highlightedWhenChecked: true, action: action));
                    place.Controls.Add(checkBox);
                    checkBoxesByItem.Add(item, checkBox);
                }
                cells.Add(place);
            }
            table.AddRow(cells.ToArray());
            Controls.Add(table);
        }
 /// <summary>
 /// Creates a block-level radio button that is part of the group.
 /// </summary>
 public BlockCheckBox CreateBlockRadioButton( bool isSelected, string label = "", PostBack postBack = null, bool autoPostBack = false )
 {
     var checkBox = new BlockCheckBox( formValue, label, postBack ) { AutoPostBack = autoPostBack };
     checkBoxesAndSelectionStates.Add( Tuple.Create<CommonCheckBox, bool>( checkBox, isSelected ) );
     return checkBox;
 }