Exemple #1
0
        /// <summary>
        /// Clears the selected value and the search field.
        /// </summary>
        public async Task Clear()
        {
            CurrentSearch = null;
            dropdownRef.Hide();

            SelectedText  = string.Empty;
            SelectedValue = default;

            await SelectedValueChanged.InvokeAsync(selectedValue);

            await SearchChanged.InvokeAsync(CurrentSearch);
        }
        private async Task HandleDropdownItemClicked(object value)
        {
            CurrentSearch = null;
            dropdownRef.Hide();

            var item = Data.FirstOrDefault(x => EqualityComparer <object> .Default.Equals(ValueField(x), value));

            SelectedText = item != null?TextField?.Invoke(item) : string.Empty;

            SelectedValue = value;

            await SelectedValueChanged.InvokeAsync(SelectedValue);

            await SearchChanged.InvokeAsync(CurrentSearch);
        }
Exemple #3
0
        private async Task OnDropdownItemClicked(object value)
        {
            CurrentSearch = null;
            dropdownRef.Hide();

            var item = Data.FirstOrDefault(x => ValueField(x).IsEqual(value));

            SelectedText = item != null?TextField?.Invoke(item) : string.Empty;

            SelectedValue = Converters.ChangeType <TValue>(value);

            await SelectedValueChanged.InvokeAsync(SelectedValue);

            await SearchChanged.InvokeAsync(CurrentSearch);

            await textEditRef?.Revalidate();
        }
Exemple #4
0
        /// <summary>
        /// Handles the search field onchange or oninput event.
        /// </summary>
        /// <param name="text">Serach value.</param>
        /// <returns>Returns awaitable task</returns>
        protected async Task OnTextChangedHandler(string text)
        {
            CurrentSearch = text ?? string.Empty;
            SelectedText  = CurrentSearch;
            dirtyFilter   = true;

            if (text?.Length >= MinLength && FilteredData.Any())
            {
                dropdownRef.Show();
            }
            else
            {
                dropdownRef.Hide();
            }

            //If input field is empty, clear current SelectedValue.
            if (string.IsNullOrEmpty(text))
            {
                await Clear();
            }

            await SearchChanged.InvokeAsync(CurrentSearch);
        }