Beispiel #1
0
        public void ResetSelection()
        {
            //SelectedKeys.Clear();
            SelectedOptions = Enumerable.Empty <IBFUDropdownOption>();
            //SelectedKey = null;

            if (MultiSelect)
            {
                //if (SelectedKeysChanged.HasDelegate)
                //    SelectedKeysChanged.InvokeAsync(SelectedKeys);
                if (SelectedOptionsChanged.HasDelegate)
                {
                    SelectedOptionsChanged.InvokeAsync(SelectedOptions);
                }
            }
            else
            {
                //if (SelectedKeyChanged.HasDelegate)
                //    SelectedKeyChanged.InvokeAsync(SelectedKey);
                if (SelectedOptionChanged.HasDelegate)
                {
                    SelectedOptionChanged.InvokeAsync(SelectedOption);
                }
            }
            StateHasChanged();
        }
Beispiel #2
0
        public void RemoveSelection(string key)
        {
            var option = ItemsSource.FirstOrDefault(x => x.Key == key);

            if (option == null)
            {
                return;
            }

            CascadedEditContext?.NotifyFieldChanged(FieldIdentifier);

            if (MultiSelect)
            {
                if (!SelectedOptions.Contains(option))
                {
                    throw new Exception("This option was not already selected.");
                }

                if (OnChange.HasDelegate)
                {
                    OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false));
                }

                SelectedOptions = SelectedOptions.Where(x => x != option).ToList();

                if (SelectedOptionsChanged.HasDelegate)
                {
                    SelectedOptionsChanged.InvokeAsync(SelectedOptions);
                }
            }
            else
            {
                if (SelectedOption != null)
                {
                    SelectedOption = null;
                    if (OnChange.HasDelegate)
                    {
                        OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false));
                    }

                    if (SelectedOptionChanged.HasDelegate)
                    {
                        SelectedOptionChanged.InvokeAsync(SelectedOption);
                    }
                }
            }
            StateHasChanged();
        }
Beispiel #3
0
        public void ResetSelection()
        {
            //SelectedKeys.Clear();
            SelectedOptions = Enumerable.Empty <IBFUDropdownOption>();
            //SelectedKey = null;

            CascadedEditContext?.NotifyFieldChanged(FieldIdentifier);

            if (MultiSelect)
            {
                if (SelectedOptionsChanged.HasDelegate)
                {
                    SelectedOptionsChanged.InvokeAsync(SelectedOptions);
                }
            }
            else
            {
                if (SelectedOptionChanged.HasDelegate)
                {
                    SelectedOptionChanged.InvokeAsync(SelectedOption);
                }
            }
            StateHasChanged();
        }
Beispiel #4
0
        public void RemoveSelection(string key)
        {
            var option = ItemsSource.FirstOrDefault(x => x.Key == key);

            if (option == null)
            {
                return;
            }

            if (MultiSelect)
            {
                if (!SelectedOptions.Contains(option))
                {
                    throw new Exception("This option was not already selected.");
                }

                if (OnChange.HasDelegate)
                {
                    OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false));
                }

                SelectedOptions = SelectedOptions.Where(x => x != option).ToList();

                if (SelectedOptionsChanged.HasDelegate)
                {
                    SelectedOptionsChanged.InvokeAsync(SelectedOptions);
                }


                //if (!SelectedKeys.Contains(key))
                //    throw new Exception("This key was not already selected.");

                //if (OnChange.HasDelegate)
                //    OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, false));

                //SelectedKeys.Remove(key);  //this used to be following the next command.  A bug?  I moved it here...

                //if (SelectedKeysChanged.HasDelegate)
                //    SelectedKeysChanged.InvokeAsync(SelectedKeys);
            }
            else
            {
                if (SelectedOption != null)
                {
                    SelectedOption = null;
                    if (OnChange.HasDelegate)
                    {
                        OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false));
                    }

                    if (SelectedOptionChanged.HasDelegate)
                    {
                        SelectedOptionChanged.InvokeAsync(SelectedOption);
                    }
                }
                //if (SelectedKey != null)
                //{
                //    SelectedKey = null;
                //    if (OnChange.HasDelegate)
                //        OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, false));

                //    if (SelectedKeyChanged.HasDelegate)
                //        SelectedKeyChanged.InvokeAsync(SelectedKey);
                //}
            }
            StateHasChanged();
        }
Beispiel #5
0
        public void AddSelection(string key)
        {
            var option = ItemsSource.FirstOrDefault(x => x.Key == key);

            if (option == null)
            {
                return;
            }

            if (MultiSelect)
            {
                if (SelectedOptions.Contains(option))
                {
                    throw new Exception("This option was already selected somehow.");
                }

                if (OnChange.HasDelegate)
                {
                    OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, true));
                }

                SelectedOptions = SelectedOptions.Append(option).ToList();

                if (SelectedOptionsChanged.HasDelegate)
                {
                    SelectedOptionsChanged.InvokeAsync(SelectedOptions);
                }

                //if (SelectedKeys.Contains(key))
                //    throw new Exception("This key was already selected.");

                //if (OnChange.HasDelegate)
                //    OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, true));

                //SelectedKeys.Add(key);

                //if (SelectedKeysChanged.HasDelegate)
                //    SelectedKeysChanged.InvokeAsync(SelectedKeys);
            }
            else
            {
                if (SelectedOption != option)
                {
                    SelectedOption = option;
                    if (OnChange.HasDelegate)
                    {
                        OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, true));
                    }
                    if (SelectedOptionChanged.HasDelegate)
                    {
                        SelectedOptionChanged.InvokeAsync(SelectedOption);
                    }
                }
                isOpen = false;
                //if (SelectedKey!= key)
                //{
                //    SelectedKey = key;
                //    if (OnChange.HasDelegate)
                //        OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, true));
                //    if (SelectedKeyChanged.HasDelegate)
                //        SelectedKeyChanged.InvokeAsync(SelectedKey);
                //}
                //isOpen = false;
            }
            StateHasChanged();
        }