This is a migrated thread and some comments may be shown as answers.

Set Selected Items

19 Answers 395 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 02 Nov 2017, 09:40 PM
I have a list of people with their email/name loaded into my autocomplete. Is there a way I can pre-load a selected person object into the autocomplete? I've tried binding the Text property to my view-model, but that doesn't seem to do anything. Any help would be appreciated.

19 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 03 Nov 2017, 05:51 PM
Hi Andrew,

The Autocomplete doesn't operate like a ComboBox, therefore it doesn't have a concept of "SelectedItem" property. That being said, you can set the Text value but there appears to be an issue with DataBinding. I've reported to the development team.

To workaround this, you'll need to the Text value on the control directly

protected override void OnAppearing()
{
    base.OnAppearing();
 
    AutoComplete.Text = "Hello World";
}


Note: If you do need a "SelectedItem" type of property you could hook into the control's SuggestionItemSelected event and update a view model property accordingly:

private void AutoComplete_OnSuggestionItemSelected(object sender, SuggestionItemSelectedEventArgs e)
{
    (BindingContext as ViewModel).SelectedItem = e.DataItem as BusinessObject;
}

Let me know if you have any further questions or concerns.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Umair
Top achievements
Rank 1
answered on 05 Nov 2017, 08:54 AM

Hi Lance,

 

I am looking for something similar as well. I tried your approach of assigning text but there are a couple of problems

1. the SuggestionList appears when I set the text programatically

2. I can't figure out how to set multiple tokens

Any help regarding these would be much appreciated. 

0
Lance | Manager Technical Support
Telerik team
answered on 06 Nov 2017, 03:48 PM
Hello andrew,

Let me address your comments directly:

1 - You can programmatically hide the SuggestionView by setting the following:

ShipperAutoComplete.ShowSuggestionView = false;

2 - You cannot yet programmatically create Tokens

You could add Tokens to the tokens collection, but the UI will not be updated. The dev team considered exposing the Token collection as an ObservableCollection but declined it, see this feedback item for the explanation from the dev team.

However
, they did approve creating an approach that lets you add Tokens programmatically, see this feedback item to upvote and follow it. At this time, if you need programmatic editing of the AutoComplete's Text, then you'll be restricted to Text mode instead of Tokens mode.

I hope I was able to answer your questions.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Safak
Top achievements
Rank 1
answered on 05 Jan 2018, 10:34 AM

Is there any information when will support setting multiple tokens?

 

Thanks

0
Yana
Telerik team
answered on 10 Jan 2018, 08:33 AM
Hello Safak,

Currently this feature request is not scheduled as the team is working on tasks with higher priority for the upcoming R1 2018 release.

You could follow the item in order to receive a notification when its status is updated.

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Dave
Top achievements
Rank 1
answered on 16 Feb 2018, 08:35 PM
Without this ability, it effectively makes this control extremely limited.  I often wonder how many real world cases your product team considers.  Otherwise it becomes a control to list for your sales team but in application - us developers suffer to communicate these short comings to our customers.
0
Yana
Telerik team
answered on 19 Feb 2018, 09:01 AM
Hi Dave,

I am sorry to hear about your disappointment with our RadAutoComplete component.  We have identified the control has limited functionality in certain scenarios and we're planning on working on this, however,  this is quite a major task, and I am afraid at this point I cannot commit to any timeframe for this.  I have raised the priority of the feature request and hopefully it will be included in one of the upcoming releases.

Thank you for sending your feedback.

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
John
Top achievements
Rank 1
answered on 19 Feb 2018, 02:35 PM
I'm evaluating the Telerik UI for Xamarin for a new client project and this issue has kicked the product into touch. No sale I am afraid!
0
Yana
Telerik team
answered on 20 Feb 2018, 11:51 AM
Hi John,

Thank you for sending your comment. I understand this functionality may be vital in certain cases and I am really sorry to hear about your decision not to use Telerik UI for Xamarin.

I am afraid I cannot add anything else regarding the requested feature to my previous post,  still , I'd like to assure you the team is working hard on improving the suite and the components' feature-set and I hope you will consider it for future projects.

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Giuseppe
Top achievements
Rank 1
answered on 14 Jan 2019, 08:30 PM

Hello,

I'm also running into a data binding issue with the RadAutoComplete control in Xamarin Forms. I tried your suggestion by setting the Text property of the control directly but it doesn't seem to do anything, although by stepping through the code, the value of Text seems to be set correctly.

I believe I'm using the latest available version, 2018.3.1122.3.

Any help or workaround would be appreciated.

Thank you.

0
Yana
Telerik team
answered on 15 Jan 2019, 10:43 AM
Hello Giuseppe,

With R3 2018 release we introduced the new and improved RadAutoCompleteView control which should replace AutoComplete. I would recommend you use the new control as it is more intuitive and provides more features. With the upcoming R1 2019 we will make it official ( now it is in beta).
I'd also like to ask you for more details on the scenario you have, so I could think of a concrete implementation with AutoCompleteView. Are you using Tokens DisplayMode?

Looking forward to your reply.

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Giuseppe
Top achievements
Rank 1
answered on 15 Jan 2019, 02:31 PM

Hello,

Let me rectify what I said: I noticed that setting the Text property was working half the time, depending on the context in which I opened the window.

Actually, I initially started using the RadAutoCompleteView, but when I set the SuggestionItemTemplate, it would not work on Android. I don't remember the error message displayed in debug, but I can try reproducing it if need be.

To answer your question, I am not using the tokens display mode, just a simple lookup with a suggestion item template.

Thank you.

0
Yana
Telerik team
answered on 16 Jan 2019, 02:43 PM
Hi Guiseppe,

Thank you for providing the details.

I have attached a sample example with RadAutoCompleteView with SuggestionItemTemplate and Text property applied. In general, the suggestions view is displayed when the user types into the input field. However, you could explicitly open it through ShowSuggestions method.
The example such approach - to show the suggestions on focus event and in this case the set Text is taken into account for showing the filtered results.

Please give it a try and let me know how it goes. Also if you could reproduce the issue on Android, that would be of great help.

I am looking forward to your reply.

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Stephen
Top achievements
Rank 1
Veteran
answered on 10 Mar 2021, 02:50 PM

I am using Xamarin Sell in an MVVM architecture...

So I am trying to "clear" the "selected item" in the autocomplete but I seem to be missing something ?

Here is a XAMl fragment where I am binding the Text property to a property on the view model ..

I "assume" I can set the property (JobInputJobSelected) to empty string and it will clear the autocomplete edit ?

It seems that the property (JobInputJobSelected) does not get changed when an item is selected either ?

IsEnabled="True"
IsClearButtonVisible="True"
ItemsSource="{Binding JobsFiltered}"
Text="{Binding JobInputJobSelected}"
SuggestMode="SuggestAppend"
TextSearchPath="JobAndDescription">

 

I am using a behavior where I get the notification like so ..

<input:RadAutoCompleteView.Behaviors>
     <xct:EventToCommandBehavior EventName="SuggestionItemSelected"
                                                             Command="{Binding JobSuggestionSelectedCommand}"/>
     </input:RadAutoCompleteView.Behaviors>

But what am I missing on how to "clear" or "reset" the text in the view model ?

0
Yana
Telerik team
answered on 12 Mar 2021, 09:39 AM

Hi Stephen,

If you use the "Plain" DisplayMode (default one), setting the Text bound property to null should clear the selection in the AutoCompleteView.  I have attached my test project to show you how it works on my side.  Please take a look and compare it to the setup you have.  Let me know if I am missing something related to the scenario.

I look forward to your reply.

Regards,
Yana
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.

0
Stephen
Top achievements
Rank 1
Veteran
answered on 17 Mar 2021, 08:18 PM

OK, setting the mode to "Mode=TwoWay" worked, I am guessing the control does not adhere to the Xamarin controls that default to 2 way binding ?

 

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/data-binding/binding-mode#two-way-bindings

 

0
Yana
Telerik team
answered on 18 Mar 2021, 08:46 AM

Hello Stephen,

Indeed, the default binding mode of the Text property is OneWay. I agree it would have been better to make it TwoWay, however, I am afraid at this point this wouldn't be possible (it will introduce a breaking change).

I hope the suggested solution would be acceptable.

Regards,
Yana
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.

0
Stephen
Top achievements
Rank 1
Veteran
answered on 18 Mar 2021, 11:45 AM

Thank you for the clarification but how do I know which controls / properties default to which binding mode ?

I don't have time to experiment so did I miss it in the documentation somewhere ?

0
Yana
Telerik team
answered on 19 Mar 2021, 05:37 AM

Hi Stephen,

You can just define the BindingMode when you need TwoWay in all cases -  this is far better and human-readable than trying to memorize and differentiate between controls and properties (such differentiation techniques leads to hidden bugs).

Still, adding the default binding mode in the documentation is a good idea, and we'll definitely have it in mind.

Regards,
Yana
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.

Tags
AutoComplete
Asked by
Andrew
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Umair
Top achievements
Rank 1
Safak
Top achievements
Rank 1
Yana
Telerik team
Dave
Top achievements
Rank 1
John
Top achievements
Rank 1
Giuseppe
Top achievements
Rank 1
Stephen
Top achievements
Rank 1
Veteran
Share this question
or