Exemplo n.º 1
0
 public string GetDependingAttribute(object selectableItem)
 {
     if (DependingDropDownOptions != null)
     {
         return(GetDependingAttributeMarkup(DependingDropDownOptions.GetDependsOnValue(selectableItem)));
     }
     else
     {
         return("");
     }
 }
Exemplo n.º 2
0
 public IDictionary <string, string> GetDependingPlaceholders()
 {
     if (DependingDropDownOptions != null)
     {
         return(DependingDropDownOptions.GetDependingPlaceholders());
     }
     else
     {
         return(new Dictionary <string, string>());
     }
 }
Exemplo n.º 3
0
 public string GetDependsOnAttribute <TModel>(ViewDataDictionary <TModel> viewData)
 {
     if (DependingDropDownOptions != null)
     {
         return(string.Format("js-depends-on={0}", DependingDropDownOptions.GetDependsOnId()));
     }
     else
     {
         return("");
     }
 }
Exemplo n.º 4
0
        /// <summary>
        ///     Initialisiert eine neue Instanz der <see cref="T:System.Object" />-Klasse.
        /// </summary>
        public DropDownModel(HtmlHelper htmlHelper, ModelMetadata modelMetaData, string propertyPath, IList selectableItems, string valuePropertyName,
                             string textPropertyName, string label, string placeholder, DependingDropDownOptions dependingDropDownOptions = null)
            : base(htmlHelper, modelMetaData, propertyPath, label)
        {
            Require.NotNull(selectableItems);

            SelectableItems   = selectableItems;
            ValuePropertyName = valuePropertyName;

            TextPropertyName = textPropertyName;
            Placeholder      = placeholder;

            DependingDropDownOptions = dependingDropDownOptions;

            IsMultiSelect = TypeHelper.IsListType(modelMetaData.ModelType);
            if (IsMultiSelect)
            {
                /*Es können mehrere Items ausgewählt sein.*/

                /* !!! Muss nach dem setzen von _valueExpression aufgerufen werden !!!*/
                if (modelMetaData.Model != null)
                {
                    ICollection selectedItems = modelMetaData.Model as ICollection;
                    if (selectedItems != null)
                    {
                        foreach (object selectedItem in selectedItems)
                        {
                            _selectedItemsValues.Add(GetSelectableItemValue(selectedItem));
                        }
                    }
                }
            }
            else
            {
                /*Es kann maximal ein Item ausgewählt sein.*/

                /* !!! Muss nach dem setzen von _valueExpression aufgerufen werden !!!*/
                _selectedItemValue = GetSelectableItemValue(modelMetaData.Model);
            }
        }