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

RadAutoCompleBox in GridViewDataColumn

4 Answers 367 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
ali
Top achievements
Rank 1
ali asked on 04 Jan 2019, 07:47 AM

I have a GridViewDataColumn, in the first column is an AutoCompleteBox for searching names in a ObservablceCollection.

I have build the RadGridView with AutoCompleteBox like this:

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Width="*" IsReadOnly="False">
     <telerik:GridViewDataColumn.CellTemplate>
      <DataTemplate DataType="{x:Type detailViews:MyViewModel}">
       <Grid>
        <Grid.ColumnDefinitions>
         <ColumnDefinition Width="*"/>
         <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <telerik:RadAutoCompleteBox DisplayMemberPath="Name"
                                    TextSearchMode="Contains"
               WatermarkContent="Suche..."
               AutoCompleteMode="Suggest"
               SelectionMode="Single"
                                    ItemsSource="{Binding Project.Names, RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}"  />
        <telerik:RadButton Grid.Column="1" HorizontalAlignment="Right" Style="{StaticResource RadImageButton}" ToolTip="Search"
                Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}, Path=DataContext.SearchFromDatabaseCommand}"
                CommandParameter="{Binding Path=.}">
         <Image Grid.Column="1" Source="{framework:ApplicationImage image}" Width="16" Height="16" />
        </telerik:RadButton>
       </Grid>
      </DataTemplate>
     </telerik:GridViewDataColumn.CellTemplate>
    </telerik:GridViewDataColumn>

 

My Problem is that the items of ObservableCollection not binded in autocompletebox. Is it possible with my type of implemetation of the AutoCompleteBox in the GridViewDataColumn?

4 Answers, 1 is accepted

Sort by
0
ali
Top achievements
Rank 1
answered on 04 Jan 2019, 08:37 AM
The next question: How can i bind selecteditem with Name (DataMemberBinding={Binding Name}) in wpf ?
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 08 Jan 2019, 11:23 AM
Hello Ali,

Thank you for the provided code snippet. 

What I would suggest you is to place the RadAutoCompleteBox in the CellEditTemplate and bind the SelectedItem property of the RadAutoCompleteBox. I have created a sample project which demonstrates how you can sync the selected item and bind the ItemsSource of the RadAutoCompleteBox control inside the cell. 

Hope this project will be helpful.

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.
0
Nebojsa Mancic
Top achievements
Rank 2
answered on 04 Mar 2020, 09:38 AM
How to get AutoCompleteBox items source to be data from one radgridview column ? Like autocomplete in Excel ? 
0
Dinko | Tech Support Engineer
Telerik team
answered on 06 Mar 2020, 11:45 AM

Hello Nebojsa,

Such behavior is not supported out of the box. Still, you can try to achieve it using custom code. You can subscribe to the CellEditEnded event of the RadGridView and create custom code that populates the collection if the search text does not exist inside. I have modified my project to demonstrate what I have in mind. You can find it attached to this reply. 

Keep in mind that this is a custom solution and may not work in all cases. But I think is a good starting point to achieve your final behavior.

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
ali
Top achievements
Rank 1
Answers by
ali
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Nebojsa Mancic
Top achievements
Rank 2
Share this question
or