RadAutoCompleBox Value is not present in Itemsource

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

    Posted 26 Jan Link to this post

    Hello,

    I have a question regarding autocompletebox component. I would like to display an icon right at the cell textbox in GridView if the entered value is not present in the itemsource. Can one solve this over binding? Which is the best way to do that?


                        <telerik:GridViewDataColumn.CellEditTemplate>
                            <DataTemplate >
                                <telerik:RadAutoCompleteBox DisplayMemberPath="Name"
                                                            TextSearchMode="Contains"
                                                            SearchText="{Binding Path=Name, Mode=TwoWay}"
                                                            AutoCompleteMode="Suggest"
                                                            SelectionMode="Single"        
                                                            VerticalAlignment="Center"
                                                            BoxesItemStyle="{StaticResource RadAutoCompleteBoxStyle}"
    NoResultsContentTemplate="{StaticResource
    RadAutoCompleteBoxNoResultsContentTemplate}"
                                                            NoResultsContent="{x:Static resources:Translations.lbl_NoMatches}"
    ItemsSource="{Binding Path=DataContext.Project.Names,
    RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}">

                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="LostFocus">
    <i:InvokeCommandAction 
    Command="{Binding RelativeSource={RelativeSource FindAncestor,
    AncestorType=UserControl},
    Path=DataContext.NewNameEnteredCommand}"
                                                                    CommandParameter="{Binding Path=.}"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </telerik:RadAutoCompleteBox>
                            </DataTemplate>

                        </telerik:GridViewDataColumn.CellEditTemplate>
  2. Dinko
    Admin
    Dinko avatar
    951 posts

    Posted 30 Jan Link to this post

    Hi ali,

    Thank you for the provided code snippet.

    You could achieve this behavior by implementing custom filtering behavior and create a bool property. Then you can bind this property to a visibility of the icon on the right side of the cell. Setting this property to Visible or Collapse will depends on the result returned inside the overridden FindMatchingItems method. I have prepared a sample project which demonstrates this. I need to point that this is a custom solution and may not work in all cases. But I think this will be a good starting point for achieving 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