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

Highlighting doesn't work while searching/filtering

3 Answers 445 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bastien
Top achievements
Rank 1
Bastien asked on 14 Aug 2017, 09:08 PM

Hello,

I'm working on a custom template of the RadGridView and I styled the SearchPanel to be only a text box part of a user control. The instant search/filtering works correctly, however, it seems that the highlighting doesn't.

While going through the source code, I saw that each column keeps a reference to the SearchPanel, in my case, it seems that this reference is null so the highlighting is not processed.

 

I simply declare the search panel in my user control and declare the user control as part of my template for RadGridView

<grid:GridViewSearchPanel Grid.Column="1" Style="{StaticResource GridViewSearchPanelStyle}"/>

 

With a style:

<Style x:Key="GridViewSearchPanelStyle" TargetType="grid:GridViewSearchPanel">
    <Setter Property="Margin" Value="5 0 0 1"/>
    <Setter Property="MaxHeight" Value="28"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    <Setter Property="HorizontalAlignment" Value="Stretch"/>
    <Setter Property="Background" Value="{StaticResource GridView_SearchPanelBackground}"/>
    <Setter Property="BorderBrush" Value="{StaticResource GridView_SearchPanelOuterBorder}"/>
    <Setter Property="SnapsToDevicePixels" Value="True"/>
 
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate x:Name="CustomSearch" TargetType="telerik:GridViewSearchPanel">
 
                <Grid UseLayoutRounding="True">
 
                    <TextBox x:Name="PART_SearchAsYouTypeTextBox"
                            Text="{Binding SearchText, Mode=TwoWay, Delay=100, UpdateSourceTrigger=PropertyChanged}"                                    MinWidth="160"
                            MaxWidth="200"
                            MaxHeight="25"
                            Margin="0 0 0 1"
                            VerticalContentAlignment="Center"
                            telerik:TextBoxBehavior.UpdateTextOnEnter="True">
                        <TextBox.IsTabStop>
                            <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="IsTabStop"/>
                        </TextBox.IsTabStop>
                    </TextBox>
 
                    <telerik:RadButton x:Name="ClearButton"
                        IsTabStop="False"
                        Style="{StaticResource ClearSearchValueButtonStyle}"
                        Command="searchPanel:GridViewSearchPanelCommands.ClearSearchValue"/>
 
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

 

So nothing fancy and for the most part this code is from Telerik's xaml files.

Am I missing something? Do I need to bind something somewhere in order for the highlighting feature to work?

 

Thank you in advance,

Bastian

3 Answers, 1 is accepted

Sort by
1
Dilyan Traykov
Telerik team
answered on 17 Aug 2017, 02:42 PM
Hello Bastien,

Due to the way the search panel logic has been set up, it needs to be part of RadGridView's control template. In other words, you will need to move the definition of your custom control inside the control template for the highlighting to work as expected.

Another approach I can suggest is to define your custom columns using the HighlightTextBlock element as demonstrated in the Custom Highlight Column demo from our SDK Samples Browser.
 
Do let me know if any of these approaches work for you.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Bastien
Top achievements
Rank 1
answered on 17 Aug 2017, 02:46 PM

Hello Dilyan,

Thank you for your answer. I ended up putting my custom control in the search panel template. That way the structure of the search panel is not altered and highlighting works as expected.

Best Regards,

Bastian

0
Dilyan Traykov
Telerik team
answered on 18 Aug 2017, 03:26 PM
Hello Bastien,

I'm glad to hear that you came up with an applicable solution. If I can be of any further assistance, please let me know.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Bastien
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Bastien
Top achievements
Rank 1
Share this question
or