RadAutoCompleteBox in RadGridView

2 posts, 0 answers
  1. David
    David avatar
    1 posts
    Member since:
    Dec 2018

    Posted 11 Dec 2018 Link to this post

    I have a RadGridView, in the first column is an AutoCompleteBox for searching articles in every row and the other GridViewDataColumn's get filled by the Information of the chosen article in the AutoCompleteBox.

    I have build the RadGridView with AutoCompleteBox like this:


                                        <Style TargetType="{x:Type telerik:GridViewCell}">
                                            <Setter Property="Template">
                                                    <ControlTemplate TargetType="{x:Type telerik:GridViewCell}">
                                                        <telerik:RadAutoCompleteBox  x:Name="AutoCompleteBox_ArtikelNr" DropDownItemTemplate="{StaticResource                                                                            CustomAutoCompleteBoxItemTemplate1}"
                                                        ItemsSource="{Binding DataContext.ArtikelAuswahl, RelativeSource={RelativeSource AncestorType={x:Type                                                                                   telerik:RadGridView}}}"
                                                        SelectedItem="{Binding RadAutoCompleteBoxArtikel_SelectedItem, Mode=TwoWay}"
                                                        FilteringBehavior="{StaticResource ArtikelSucheFilteringBehavior}"


    I fill the Columns with Information I seleced in the AutoCompleteBox like this:

            private void AutoCompleteBoxArtikel_SelectionChanged(object sender, SelectionChangedEventArgs e)
                if (e.AddedItems.Count > 0)
                    if (currentTabellenDaten != null)
                        //int rowIndex = this.radGridView1.Items.IndexOf(this.radGridView1.SelectedItem);
                        //rowIndex = rowIndex + 1;
                        TabellenDaten geladeneTabellenDaten = new TabellenDaten();
                        bool ok = MainViewModel.TabellenDatenController.LoadTabellenDaten(((Artikel)e.AddedItems[0]).ArtikelNr, geladeneTabellenDaten);
                        currentTabellenDaten.ArtikelNr = geladeneTabellenDaten.ArtikelNr;
                        currentTabellenDaten.ArtikelBez1 = geladeneTabellenDaten.ArtikelBez1;
                        currentTabellenDaten = null;
                        geladeneTabellenDaten = null;


    My Problem is, that I can't get the Row index of the Current edited AutoCompleteBox(I tried like in the Code commented out but doesn't work), so when I want to edit a Row that already has some Information (selecting an other article in the AutoCompleteBox) , the new Information should be written in the same Row.


    Is it possible with my type of implemetation of the AutoCompleteBox in the RadGridView?

    Is there an other or better way to have an AutoCompleteBox in the RadGridview?


    I hope you can understand my Problem and I'm sorry for my bad english skills.


  2. Dilyan Traykov
    Dilyan Traykov avatar
    1092 posts

    Posted 14 Dec 2018 Link to this post

    Hello David,

    You can get ahold of the index of the row which was edited by using the ParentOfType extension method on the RadAutoCompleteBox. Here's how you can do so in the AutoCompleteBoxArtikel_SelectionChanged method:

    var acb = sender as RadAutoCompleteBox;
    var row = acb.ParentOfType<GridViewRow>();
    var item = row.DataContext;
    var rowIndex = row.GridViewDataControl.Items.IndexOf(item);

    On a side note, please have in mind that the recommended approach for specifying a custom template for the cells is via the column's CellTemplate property:

            <telerik:RadAutoCompleteBox  x:Name="AutoCompleteBox_ArtikelNr" ... />

    I hope you find this helpful. Please let me know if the aforementioned approach for getting the row index works for you.

    Dilyan Traykov
    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