Unplanned
Last Updated: 02 Aug 2022 11:38 by ADMIN
Vladimir
Created on: 21 Jul 2022 11:00
Category: AutoCompleteBox
Type: Feature Request
3
RadAutoCompleteBox: Add Clear all button

Please add a simple way to show "Clear all" button in a MultiSelect mode to clear all selected items, so we don't have to customize entire control template. Added properties could be at least those: IsClearAllButtonVisible and ClearAllButtonTemplate.

 

Best regards,

Vladimir

2 comments
ADMIN
Stenly
Posted on: 02 Aug 2022 11:38

Hello Vladimir,

I am writing to you to propose an alternative solution, which will not require extracting the default template of the RadAutoCompleteBox control. The suggestion consists of modifying the SelectedItems property of the control, which can be set to null on a button click. This way, all of the selected items will be removed.

The following code snippet shows this suggestion's implementation:

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
    <telerik:RadAutoCompleteBox x:Name="AutoComplete"
                                AutoCompleteMode="Suggest"  
                                DisplayMemberPath="Name" 
                                TextSearchPath="Capital" 
                                TextSearchMode="Contains" 
                                WatermarkContent="Select a country..."
                                MinWidth="200"
                                SelectionMode="Multiple"/>
    <telerik:RadButton Name="deleteBtn" Content="X" Click="deleteBtn_Click" />
</StackPanel>
private void deleteBtn_Click(object sender, RoutedEventArgs e)
{
    this.AutoComplete.SelectedItems = null;
}

 

The button's visibility and visual representation can be controlled through its Visibility and Template properties.

With this said, may I ask if you could give this approach a try and let me know whether it would work for you?

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

ADMIN
Stenly
Posted on: 28 Jul 2022 07:09

Hello Vladimir,

This suggestion seems like a good addition to the API of the RadAutoCompleteBox control. As a result of this, I have logged a new item in our internal backlog and have linked it to this item, so that you could get notified via e-mail when its status gets changed.

In addition, I have updated your Telerik points as a token of gratitude for bringing this to our attention.

In the meantime, we have an SDK example, which shows how to achieve part of the desired functionality. It demonstrates how to clear the selected item in a single selection scenario, however, it could be used as a starting point for implementing this functionality when having multi-selection. The example achieves this by modifying the default template of the control to include a button and by executing additional removal logic. It could be found in our SDK Samples Browser, as well as in our GitHub repository.

I hope the provided information will be of help to you.

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.