RadAutoComplete - How To Reset Selected Value From Another UI Toggle/Button

1 Answer 63 Views
AutoComplete
billy
Top achievements
Rank 2
Iron
Iron
Iron
billy asked on 16 Oct 2023, 04:45 PM

I have a RadAutoComplete which works fine. But what I need to do is to be able to Clear the selected value programmatically (not using the clear button).

We have a use case where a user can have a selected value from the autocomplete, but then they use a toggle/button to change how the screen performs an API (not using the RadAutoCompelte selected value, but a different property), but when the user selects that toggle, it still leaves the selected value in the UI.

The user can be confused as to what style lookup they are performing seeing as when they toggle the other style lookup using the toggle button, the selected value from the autocomplete is not cleared.

I have been unable to find an event or option to clear the selected value in the display.

Can you tell me if there is a way to do this?

thanks

Billy

1 Answer, 1 is accepted

Sort by
1
Accepted
Didi
Telerik team
answered on 18 Oct 2023, 10:40 AM

Hi Billy,

Thank you for the provided details. 

It depends whether the display mode is set to Tokens or it is Plain

If you want to clear the Text in the AutoComplete, and displayMode is Plain, then set the text to empty string or null. The Text property is bindable property: 

private void Switch_Toggled(object sender, ToggledEventArgs e)
{
    this.auto.Text = "";
}

    <VerticalStackLayout>
        <Switch Toggled="Switch_Toggled"/>
        <telerik:RadAutoComplete x:Name="auto" />

    </VerticalStackLayout>

If the DisplayMode is Tokens then you can clear the tokens collection: 

private void Switch_Toggled(object sender, ToggledEventArgs e)
{
    this.auto.Tokens.Clear();
}

    <VerticalStackLayout>
        <Switch Toggled="Switch_Toggled"/>
        <telerik:RadAutoComplete x:Name="auto" DisplayMode="Tokens"/>

    </VerticalStackLayout>

 

Regards,
Didi
Progress Telerik

A brand new .NET MAUI course was just added to the Virtual Classroom. The training course is developed to help you get started with the Telerik UI for .NET MAUI components and features. It aims to put you in the shoes of an engineer who adds new features to an existing application. You can check it out at https://learn.telerik.com
Pavani
Top achievements
Rank 1
commented on 27 Oct 2023, 08:37 AM

How to set Values to the autocomplete ?
Didi
Telerik team
commented on 27 Oct 2023, 08:41 AM

Depending on the display mode:

Tokens DisplayMode ->  you have to use the Tokens collection,

Plain DisplayMode -> you have to use the Text property. 
How to get the data requires custom logic implementation. 

Tags
AutoComplete
Asked by
billy
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Didi
Telerik team
Share this question
or