Set Selected Items

6 posts, 0 answers
  1. Andrew
    Andrew avatar
    1 posts
    Member since:
    Dec 2012

    Posted 02 Nov 2017 Link to this post

    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.
  2. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    503 posts

    Posted 03 Nov 2017 Link to this post

    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
  3. Umair
    Umair avatar
    4 posts
    Member since:
    Apr 2016

    Posted 05 Nov 2017 Link to this post

    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. 

  4. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    503 posts

    Posted 06 Nov 2017 Link to this post

    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
  5. Safak
    Safak avatar
    6 posts
    Member since:
    Mar 2016

    Posted 05 Jan in reply to Lance | Tech Support Engineer, Sr. Link to this post

    Is there any information when will support setting multiple tokens?

     

    Thanks

  6. Yana
    Admin
    Yana avatar
    4630 posts

    Posted 10 Jan Link to this post

    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
Back to Top