Esempio n. 1
0
        internal async Task OnInternalSelectAsync(BSelectOptionBase <TValue> item)
        {
            var args = new BChangeEventArgs <BSelectOptionBase <TValue> >();

            args.NewValue = item;
            args.OldValue = SelectedOption;
            if (OnChanging.HasDelegate)
            {
                await OnChanging.InvokeAsync(args);

                if (args.DisallowChange)
                {
                    return;
                }
            }

            await dropDownOption.Instance.CloseDropDownAsync(dropDownOption);

            SelectedOption = item;
            SetFieldValue(item.Value, true);
            Value = item.Value;
            if (dict != null)
            {
                dict.TryGetValue(Value, out var label);
                Label = label;
            }
            if (OnChange.HasDelegate)
            {
                await OnChange.InvokeAsync(args);
            }
            EnableClearButton = false;
            StateHasChanged();
        }
Esempio n. 2
0
        protected override void FormItem_OnReset(object value, bool requireRerender)
        {
            var enumValue = (TValue)value;

            if (nullable != null && value == null)
            {
                SelectedOption = null;
            }
            else
            {
                Label = dict[enumValue];
                Value = enumValue;
            }
            if (ValueChanged.HasDelegate)
            {
                _ = ValueChanged.InvokeAsync(Value);
            }
            else
            {
                StateHasChanged();
            }
        }