RadAutoCompleBox in GridViewDataColumn

5 posts, 1 answers
  1. ali
    ali avatar
    5 posts
    Member since:
    Jan 2019

    Posted 04 Jan 2019 Link to this post

    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?

  2. ali
    ali avatar
    5 posts
    Member since:
    Jan 2019

    Posted 04 Jan 2019 in reply to ali Link to this post

    The next question: How can i bind selecteditem with Name (DataMemberBinding={Binding Name}) in wpf ?
  3. Answer
    Dinko
    Admin
    Dinko avatar
    1113 posts

    Posted 08 Jan 2019 Link to this post

    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.
  4. Nebojsa Mancic
    Nebojsa Mancic avatar
    4 posts
    Member since:
    Apr 2010

    Posted 04 Mar in reply to Dinko Link to this post

    How to get AutoCompleteBox items source to be data from one radgridview column ? Like autocomplete in Excel ? 
  5. Dinko
    Admin
    Dinko avatar
    1113 posts

    Posted 06 Mar Link to this post

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