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

AutoCompleteView

6 Answers 190 Views
AutoCompleteView
This is a migrated thread and some comments may be shown as answers.
Klejda
Top achievements
Rank 1
Klejda asked on 18 Feb 2019, 12:14 PM

Hello , 

I want to add  every row that i select from the AutoCompleteView into a grid that will be located in the same page as the AutoCompleteView .

My question is how can i get the selected element and add it to the grid ? 

6 Answers, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 18 Feb 2019, 04:06 PM
Hi Klejda,

I have created a sample that shows how to achieve the described scenario. The solution works in both scenarios: DisplayMode="Plain" or the DisplayMode="Tokens".

Please take a look at the attached project and let me know if you have any additional questions on this.

Regards,
Didi
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
Klejda
Top achievements
Rank 1
answered on 19 Feb 2019, 06:46 AM

The problem is that we are using Xamarin Forms and i need to have my events in the ViewModel and nothing in the back code . 

So I want to get the SelectedItem in my ViewModel where i can create and fire my event . I saw your example but it is not what i am looking for .

 

0
Didi
Telerik team
answered on 19 Feb 2019, 12:12 PM
Hello Klejda,

Currently, the RadAutoCompleteView does not provide a command equivalent to the SuggestionItemSelected event. In this case you will need to use a Xamarin.Forms EventToCommandBehavior. 

You'll get the event args as a command parameter and add the selected item to the RadDataGrid ItemsSource.
 
For example:

<telerikInput:RadAutoCompleteView.Behaviors>
    <local:EventToCommandBehavior EventName="SuggestionItemSelected"
                        Command="{Binding SuggestionSelectedCommand}"/>
</telerikInput:RadAutoCompleteView.Behaviors>

public Command SuggestionSelectedCommand { get; set; }

private void OnSuggestedSelected(object obj)
{
    if (obj is SuggestionItemSelectedEventArgs e)
    {
        var item = e.DataItem;
        this.SelectedItems.Add((Person)item);
    }
}

Please take a look at the attached project how this could be achieved and let me know if you have any additional questions or concerns.

Regards,
Didi
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
Klejda
Top achievements
Rank 1
answered on 19 Feb 2019, 12:44 PM

It worked perfectly , exactly what i was looking for . 

No , at the moment that i want to remove a selected item , i want to remove it from the grid too . 

Is there any way to do this ?

0
Klejda
Top achievements
Rank 1
answered on 19 Feb 2019, 12:44 PM
Now*
0
Accepted
Didi
Telerik team
answered on 19 Feb 2019, 05:15 PM
Hi Klejda,

I have modified the attached project regarding how to Add and Remove items to the RadDataGrid using the Tokens Collection of the AutoCompleteView control. Please take a look at the MyConverter.cs and MainPage.xaml files how this could be achieved. 

I hope this could help.

Regards,
Didi
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
Tags
AutoCompleteView
Asked by
Klejda
Top achievements
Rank 1
Answers by
Didi
Telerik team
Klejda
Top achievements
Rank 1
Share this question
or