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

RadAutoCompleBox Value is not present in Itemsource

1 Answer 62 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
ali
Top achievements
Rank 1
ali asked on 26 Jan 2019, 08:16 AM

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>

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 30 Jan 2019, 12:42 PM
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.
Tags
AutoCompleteBox
Asked by
ali
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or