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

[Solved] RowTemplate and Filtering

3 Answers 127 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Valentijn
Top achievements
Rank 1
Valentijn asked on 10 Nov 2010, 07:22 PM
Hi

I have a gridview with a custom row template and want to add a filterdescriptor, but the filterdescriptor i added is not working. The filter does work when i don't use a template.

This is my custom template:

 

 

 

<ControlTemplate x:Key="MyCustomRowTemplate" TargetType="telerik:GridViewRow">

 

 

 

 

<Border x:Name="rowsContainer" Padding="8,8,8,0">

 

 

 

 

<Border x:Name="selectedRow"

 

 

 

BorderThickness="1" BorderBrush="#FF777777">

 

 

 

 

<Grid Margin="10">

 

 

 

 

<Grid.RowDefinitions>

 

 

 

 

<RowDefinition Height="23" />

 

 

 

 

<RowDefinition Height="23" />

 

 

 

 

<RowDefinition Height="23" />

 

 

 

 

<RowDefinition Height="23" />

 

 

 

 

<RowDefinition Height="23" />

 

 

 

 

<RowDefinition Height="23" />

 

 

 

 

<RowDefinition Height="23" />

 

 

 

 

<RowDefinition Height="23" />

 

 

 

 

</Grid.RowDefinitions>

 

 

 

 

<Grid.ColumnDefinitions>

 

 

 

 

<ColumnDefinition Width="250"/>

 

 

 

 

<ColumnDefinition Width="*" />

 

 

 

 

</Grid.ColumnDefinitions>

 

 

 

 

<TextBlock Text="{Binding Source={StaticResource LocalizedStrings}, Path=stringResources.lblDate}"

 

 

 

Grid.Column="0" Grid.Row="0"

 

 

 

VerticalAlignment="Top" HorizontalAlignment="Left"

 

 

 

FontWeight="Bold" Margin="0" />

 

 

 

 

<TextBlock Text="{Binding Date, StringFormat='{}{0:d}'}"

 

 

 

Grid.Column="0" Grid.Row="1"

 

 

 

VerticalAlignment="Top" HorizontalAlignment="Left"

 

 

 

Margin="0" />

 

 

 

 

<TextBlock Text="{Binding Source={StaticResource LocalizedStrings}, Path=stringResources.lblValidTill}"

 

 

 

Grid.Column="1" Grid.Row="0"

 

 

 

VerticalAlignment="Top" HorizontalAlignment="Left"

 

 

 

FontWeight="Bold" Margin="0" />

 

 

 

 

<TextBlock Text="{Binding ValidTill, StringFormat='{}{0:d}'}"

 

 

 

Grid.Column="1" Grid.Row="1"

 

 

 

VerticalAlignment="Top" HorizontalAlignment="Left"

 

 

 

Margin="0" />

 

 

 

 

<TextBlock Text="{Binding Source={StaticResource LocalizedStrings}, Path=stringResources.lblHomologation}"

 

 

 

Grid.Column="0" Grid.Row="2"

 

 

 

VerticalAlignment="Top" HorizontalAlignment="Left"

 

 

 

FontWeight="Bold" Margin="0" />

 

 

 

 

<TextBlock Text="{Binding Homologation.Code}"

 

 

 

Grid.Column="0" Grid.Row="3"

 

 

 

VerticalAlignment="Top" HorizontalAlignment="Left"

 

 

 

Margin="0" />

 

 

 

 

<TextBlock Text="{Binding Source={StaticResource LocalizedStrings}, Path=stringResources.lblLanes}"

 

 

 

Grid.Column="0" Grid.Row="4"

 

 

 

VerticalAlignment="Top" HorizontalAlignment="Left"

 

 

 

FontWeight="Bold" Margin="0" />

 

 

 

 

<TextBlock Text="{Binding Lanes}"

 

 

 

Grid.Column="0" Grid.Row="5"

 

 

 

VerticalAlignment="Top" HorizontalAlignment="Left"

 

 

 

Margin="0" />

 

 

 

 

<TextBlock Text="{Binding Source={StaticResource LocalizedStrings}, Path=stringResources.lblRemarks}"

 

 

 

Grid.Column="0" Grid.Row="6"

 

 

 

VerticalAlignment="Top" HorizontalAlignment="Left"

 

 

 

FontWeight="Bold" Margin="0" />

 

 

 

 

<TextBlock Text="{Binding Remarks}"

 

 

 

Grid.Column="0" Grid.Row="7"

 

 

 

VerticalAlignment="Top" HorizontalAlignment="Left"

 

 

 

Margin="0" />

 

 

 

 

 

</Grid>

 

 

 

 

</Border>

 

 

 

 

</Border>

 

 

 

 

</ControlTemplate>

 

 

 

 

<Style x:Key="rowStyle" TargetType="telerik:GridViewRow">

 

 

 

 

<Setter Property="Template" Value="{StaticResource MyCustomRowTemplate}" />

 

 

 

 

</Style>

 


my gridview:

<

 

 

telerik:RadGridView AutoGenerateColumns="False" CanUserReorderColumns="False" ShowColumnHeaders="False" ColumnWidth="*" Grid.ColumnSpan="2" IsFilteringAllowed="False" ItemsSource="{Binding Path=CenterHomologations}" Margin="176,0,96,6" Name="gridHomologations" ShowGroupPanel="False" ShowInsertRow="False" SelectionChanged="gridHomologations_SelectionChanged" RowStyle="{StaticResource rowStyle}">

 

 

 

 

 

</telerik:RadGridView>

 


And this is the filter i add via code behind:

Telerik.Windows.Data.

 

FilterDescriptor filter = new Telerik.Windows.Data.FilterDescriptor("Deleted", Telerik.Windows.Data.FilterOperator.IsEqualTo, false);

 

 

 

this.gridHomologations.FilterDescriptors.Add(filter);

Does anybody know how to implement filtering when using a custom row template?

 

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 11 Nov 2010, 08:15 AM
Hello Valentijn,

 On this demo the filtering is working fine together with custom row style. 

Greetings,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Valentijn
Top achievements
Rank 1
answered on 15 Nov 2010, 01:59 PM
Hi Vlad

The problem is that the grid with a custom row layout does not watch for changes to the data, while the one without does! So when one of the rows is changed (in my example , the deleted boolean gets to be true) the filter is not watching it.

You need to manually do something like this in code behind to get it to repaint and use its filterdescriptor:

            Telerik.Windows.Data.FilterDescriptor filter = new Telerik.Windows.Data.FilterDescriptor("Deleted", Telerik.Windows.Data.FilterOperator.IsEqualTo, false);
            this.gridHomologations.FilterDescriptors.Clear();
            this.gridHomologations.FilterDescriptors.Add(filter);


Your demo works because it gets repainted when the filterdescriptors are changed.

This is a bug! Since it works without the custom layout!

Best regards

Valentijn
0
Vlad
Telerik team
answered on 15 Nov 2010, 02:04 PM
Hi,

The grid reaction on data changes is not related to the grid templates. 

Regards,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Valentijn
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Valentijn
Top achievements
Rank 1
Share this question
or