Completed
Last Updated: 15 Jan 2024 15:35 by ADMIN
Suryateja
Created on: 09 Jan 2024 22:19
Category: DropDownList
Type: Feature Request
0
Request for Event Trigger Feature During Filtering in Telerik Blazor Dropdown Component
Dear Team,

I am reaching out to suggest an enhancement to the existing filtering feature in the Telerik Blazor dropdown component. Currently, the filtering capability is quite useful, but it would be even more powerful if there was an event trigger during the filtering process. This event would allow developers to execute custom logic while a user is typing in the dropdown field. The ability to respond in real-time as the input changes would significantly enrich the interactivity and functionality of the dropdown, enabling more dynamic and user-tailored experiences. Implementing this feature could greatly enhance the flexibility and utility of the dropdown component. Thank you for considering this enhancement, and I eagerly anticipate its potential integration in future updates.

Kind regards,
Suryateja KONDLA
3 comments
ADMIN
Dimo
Posted on: 15 Jan 2024 15:35

Hi Suryateja,

The OnRead event already provides the described functionality. The additional benefit is that OnRead provides more information than just the filter string, so the app can perform various customizations that are related to the incoming data.

@using Telerik.DataSource
@using Telerik.DataSource.Extensions

<p>Search (filter) by typing letters (aa - zz)</p>

<p>DropDownList value: @DropDownListValue</p>

<p>DropDownList filter string: @DropDownListFilterString</p>

<TelerikDropDownList TItem="@Product" TValue="@int" OnRead="@GetItems"
                     @bind-Value="@DropDownListValue"
                     ValueField="@nameof(Product.Id)"
                     TextField="@nameof(Product.Name)"
                     Filterable="true"
                     FilterOperator="@StringFilterOperator.Contains"
                     Width="300px">
</TelerikDropDownList>

@code {
    int DropDownListValue { get; set; }
    string DropDownListFilterString { get; set; } = string.Empty;

    List<Product> Products { get; set; } = new();

    async Task GetItems(DropDownListReadEventArgs args)
    {
        if (args.Request.Filters.Any())
        {
            FilterDescriptor filter = (FilterDescriptor)args.Request.Filters.First();
            DropDownListFilterString = filter.Value.ToString()!;
        }
        else
        {
            DropDownListFilterString = "(none)";
        }

        await Task.Delay(1);

        var result = Products.ToDataSourceResult(args.Request);

        args.Data = result.Data;
        args.Total = result.Total;
    }

    protected override void OnInitialized()
    {
        Products = new List<Product>();
        for (int i = 1; i <= 99; i++)
        {
            Products.Add(new Product()
            {
                Id = i,
                Name = $"Product {((char)(i % 27 + 64)).ToString()}{((char)(i % 27 + 64)).ToString()}"
            });
        }

        base.OnInitialized();
    }

    public class Product
    {
        public int Id { get; set; }
        public string Name { get; set; } = default!;
    }
}

 

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Suryateja
Posted on: 12 Jan 2024 22:58
<TelerikDropDownList OnFilter="OnFiltering" 
                     Data="@myDdlData" 
                     TextField="MyTextField" 
                     ValueField="MyValueField" 
                     @bind-Value="selectedValue">
</TelerikDropDownList>

@code {
    private void OnFiltering(FilterEventArgs args)
    {
        var value = args.Value; 
        // Capture the keywords typed in the search box of the dropdown.
        // Here, your custom logic goes where you can use the default filtering 
        // enum like contains, starts with, or ends with.
    }
}


ADMIN
Dimo
Posted on: 10 Jan 2024 09:53

Hi Suryateja,

The DropDownList already provides an event, which fires during filtering - OnRead. If you bind the component with OnRead instead of Data, you will be able to know the current filter string and customize the app behavior (or the DropDownList data).

Will this work for you and if not, please elaborate what exactly are you trying to do.

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!