/// <summary> /// Creates a form item with a change based check box list, which is a check box list that is based on changes to the selections rather than the absolute /// set of selected items. /// </summary> /// <typeparam name="ItemIdType"></typeparam> /// <param name="label"></param> /// <param name="items"></param> /// <param name="modificationMethod">A method that executes the change handlers of the items that were selected or deselected on this post back.</param> /// <param name="caption"></param> /// <param name="includeSelectAndDeselectAllButtons"></param> /// <param name="numberOfColumns"></param> /// <param name="action"></param> /// <param name="cellSpan"></param> /// <param name="textAlignment"></param> /// <param name="validationPredicate"></param> /// <returns></returns> public static FormItem GetFormItem <ItemIdType>( FormItemLabel label, IEnumerable <ChangeBasedListItemWithSelectionState <ItemIdType> > items, out Action modificationMethod, string caption = "", bool includeSelectAndDeselectAllButtons = false, byte numberOfColumns = 1, FormAction action = null, int?cellSpan = null, TextAlignment textAlignment = TextAlignment.NotSpecified, Func <bool> validationPredicate = null) { var itemArray = items.ToArray(); var selectedItemIds = itemArray.Where(i => i.IsSelected).Select(i => i.Item.Item.Id); var uiSelectedItemIds = itemArray.Where(i => i.IsSelectedInUi).Select(i => i.Item.Item.Id); var checkBoxList = new ChangeBasedCheckBoxList <ItemIdType>( itemArray.Select(i => i.Item), selectedItemIds, caption, includeSelectAndDeselectAllButtons, numberOfColumns, uiSelectedItemIds, action); modificationMethod = checkBoxList.ModifyData; return(FormItem.Create( label, checkBoxList, cellSpan: cellSpan, textAlignment: textAlignment, validationGetter: control => new EwfValidation( (pbv, validator) => { if (validationPredicate != null && !validationPredicate()) { return; } control.Validate(pbv); }))); }
/// <summary> /// Creates a form item with a change based check box list, which is a check box list that is based on changes to the selections rather than the absolute /// set of selected items. /// </summary> /// <typeparam name="ItemIdType"></typeparam> /// <param name="label"></param> /// <param name="items"></param> /// <param name="selectedItemIds"></param> /// <param name="modificationMethod">A method that executes the change handlers of the items that were selected or deselected on this post back.</param> /// <param name="caption"></param> /// <param name="includeSelectAndDeselectAllButtons"></param> /// <param name="numberOfColumns"></param> /// <param name="uiSelectedItemIds"></param> /// <param name="postBack"></param> /// <param name="cellSpan"></param> /// <param name="textAlignment"></param> /// <param name="validationPredicate"></param> /// <param name="validationList"></param> /// <returns></returns> public static FormItem GetFormItem <ItemIdType>( FormItemLabel label, IEnumerable <ChangeBasedListItem <ItemIdType> > items, IEnumerable <ItemIdType> selectedItemIds, out Action modificationMethod, string caption = "", bool includeSelectAndDeselectAllButtons = false, byte numberOfColumns = 1, IEnumerable <ItemIdType> uiSelectedItemIds = null, PostBack postBack = null, int?cellSpan = null, TextAlignment textAlignment = TextAlignment.NotSpecified, Func <bool> validationPredicate = null, ValidationList validationList = null) { var checkBoxList = new ChangeBasedCheckBoxList <ItemIdType>( items, selectedItemIds, caption, includeSelectAndDeselectAllButtons, numberOfColumns, uiSelectedItemIds ?? selectedItemIds, postBack); modificationMethod = checkBoxList.ModifyData; return(FormItem.Create( label, checkBoxList, cellSpan: cellSpan, textAlignment: textAlignment, validationGetter: control => new EwfValidation( (pbv, validator) => { if (validationPredicate != null && !validationPredicate()) { return; } control.Validate(pbv); }, validationList ?? EwfPage.Instance.DataUpdate))); }