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

DataContext, Stored Procedure and bindings.

1 Answer 18 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Grzesiek
Top achievements
Rank 2
Grzesiek asked on 16 Jan 2019, 06:43 AM

     Hello,

In my database I have stored procedure which returns me the clients list. I'm binding it to AutoCompleteBox like below:

 

var y = DC.ClientGetAll();
ClientList.ItemsSource = new ObservableCollection<ClientGetAllResult>(y);

 

In XAML:

                <telerik:RadAutoCompleteBox x:Name="ClientList" ItemsSource="{Binding}"
                   TextSearchMode="Contains"
                                            DisplayMemberPath="Name" 
                                            AutoCompleteMode="SuggestAppend" 
                                            SelectionMode="Single" Margin="107,72,16,0" 
                                            VerticalAlignment="Top"
                                            SelectedItem="{Binding}"
                                            />

 

And everything is OK.

But now I want, to create edit form for my users and after open form, AutoCompleteBox should show selected item (by ID).

I was tried everything, but without result.

Can you help me?

1 Answer, 1 is accepted

Sort by
0
Dinko
Telerik team
answered on 18 Jan 2019, 12:57 PM
Hi Grzesiek,

If I have understood your scenario correctly, you want the dropdown items to be displayed by Value property but when you select an item to be displayed by ID property. IF this is the case, I can't suggest you approach which you could try in Single selection mode. In multiple selection mode, you could try using BoxesItemTemplate and specify custom DataTemplate in which there is TextBlock bind to a different property.

An approach which you could try (in Single mode) is to set the DisplayMemberPath property to ID and set the TextSearchPath to Value. This way the control will search for an item using Value property and shows ID property. You can additionally customize the DropDownItem by specifying DropDownItemTemplate property so it contains more information.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
AutoCompleteBox
Asked by
Grzesiek
Top achievements
Rank 2
Answers by
Dinko
Telerik team
Share this question
or