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

custom filter template losing binding

3 Answers 61 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Piotr
Top achievements
Rank 1
Piotr asked on 29 Jan 2013, 08:08 AM
For FilteringControl we written template. Main idea was to reverse order of items in ValueList. 
Right now i faced with issue. 
First time when i open filter by clicking filtering icon and select/deselect one position filtering works. So far so good. 
I click outside filter window (control), it lose focus and hide. 
Then open it again, repeat operation. Filtering not works. 
But only on DistinctValuesList. Range filters works. 

I presume source of issue is binding to IsActive property. 
Below FilteringControl template code:
<ControlTemplate TargetType="telerik:FilteringControl">
  <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="1" Margin="{TemplateBinding Margin}">
    <Border BorderBrush="{StaticResource ControlInnerBorder}" BorderThickness="1" Background="{TemplateBinding Background}">
      <Grid>
        <StackPanel HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" MaxWidth="350" Margin="{TemplateBinding Padding}" MinWidth="200" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
          <StackPanel x:Name="PART_DistinctFilter" Visibility="{TemplateBinding DistinctFiltersVisibility}">
            <CheckBox x:Name="PART_SelectAllCheckBox" IsChecked="{Binding SelectAll, Mode=TwoWay}" Margin="0,2" telerik:LocalizationManager.ResourceKey="GridViewFilterSelectAll" telerik:StyleManager.Theme="{StaticResource Theme2}"/>
            <ListBox x:Name="PART_DistinctValuesList" ScrollViewer.HorizontalScrollBarVisibility="Auto" ItemsSource="{Binding DistinctValues, Converter={StaticResource reverseItemsSourceConverter}}" ItemContainerStyle="{StaticResource DistinctValueListBoxItemStyle}" SelectionMode="Multiple" telerik:StyleManager.Theme="{StaticResource Theme2}">
              <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                  <VirtualizingStackPanel MaxHeight="242"/>
                </ItemsPanelTemplate>
              </ListBox.ItemsPanel>
              <ListBox.ItemTemplate>
                <DataTemplate>
                  <CheckBox Content="{Binding ConvertedValue, Converter={StaticResource DistinctValueConverter}}" IsChecked="{Binding IsActive, Mode=TwoWay}" telerik:StyleManager.Theme="{StaticResource Theme2}" VerticalContentAlignment="Center"/>
                </DataTemplate>
              </ListBox.ItemTemplate>
            </ListBox>
          </StackPanel>
          <StackPanel Margin="0,2" Visibility="{TemplateBinding FieldFiltersVisibility}">
            <TextBlock Margin="0,2,0,0" telerik:LocalizationManager.ResourceKey="GridViewFilterShowRowsWithValueThat"/>
            <telerik:RadComboBox x:Name="PART_Filter1ComboBox" ItemTemplate="{StaticResource ActionTemplate}" ItemsSource="{Binding AvailableActions}" Margin="0,2,0,2" SelectedItem="{Binding Filter1.Operator, Mode=TwoWay}" telerik:StyleManager.Theme="{StaticResource Theme2}"/>
            <ContentControl x:Name="PART_Filter1ContentControl" DataContext="{Binding Filter1}" HorizontalContentAlignment="Stretch" IsEnabled="{Binding Operator, Converter={StaticResource FilterOperatorToFilterEditorIsEnabledConverter}}" Margin="0, 2" VerticalContentAlignment="Stretch"/>
            <telerik:RadComboBox x:Name="PART_LogicalOperatorsComboBox" ItemTemplate="{StaticResource LogicalOperatorTemplate}" ItemsSource="{Binding LogicalOperators}" Margin="0,2" SelectedItem="{Binding FieldFilterLogicalOperator, Mode=TwoWay}" telerik:StyleManager.Theme="{StaticResource Theme2}"/>
            <telerik:RadComboBox x:Name="PART_Filter2ComboBox" ItemTemplate="{StaticResource ActionTemplate}" ItemsSource="{Binding AvailableActions}" Margin="0,2" SelectedItem="{Binding Filter2.Operator, Mode=TwoWay}" telerik:StyleManager.Theme="{StaticResource Theme2}"/>
            <ContentControl x:Name="PART_Filter2ContentControl" DataContext="{Binding Filter2}" HorizontalContentAlignment="Stretch" IsEnabled="{Binding Operator, Converter={StaticResource FilterOperatorToFilterEditorIsEnabledConverter}}" Margin="0, 2" VerticalContentAlignment="Stretch"/>
          </StackPanel>
          <Grid>
            <Grid.ColumnDefinitions>
              <ColumnDefinition/>
              <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Button x:Name="PART_ApplyFilterButton" Grid.Column="0" Height="22" Margin="0,2,2,2" telerik:LocalizationManager.ResourceKey="GridViewFilter" telerik:StyleManager.Theme="{StaticResource Theme2}" Visibility="{TemplateBinding FilterButtonVisibility}"/>
            <Button x:Name="PART_ClearFilterButton" Grid.Column="1" Height="22" Margin="2,2,0,2" telerik:LocalizationManager.ResourceKey="GridViewClearFilter" telerik:StyleManager.Theme="{StaticResource Theme2}"/>
          </Grid>
        </StackPanel>
        <telerik:RadButton x:Name="PART_FilterCloseButton" HorizontalAlignment="Right" Height="13" Margin="{TemplateBinding Padding}" telerik:StyleManager.Theme="{StaticResource Theme2}" VerticalAlignment="Top" Width="13">
          <Path Data="M4,4L5,4 5,5 4,5z M0,4L1,4 1,5 0,5z M3,3L4,3 4,4 3,4z M1,3L2,3 2,4 1,4z M2,2L3,2 3,3 2,3z M4,0L5,0 5,1 4,1 4,2 3,2 3,0.99999994 4,0.99999994z M0,0L1,0 1,0.99999994 2,0.99999994 2,2 1,2 1,1 0,1z" Fill="{StaticResource GridView_IndicatorPrimaryColor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Height="6" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Width="6"/>
        </telerik:RadButton>
      </Grid>
    </Border>
  </Border>
</ControlTemplate>

and usage:
<telerik:GridViewDataColumn DataMemberBinding="{Binding DealDate.Date}" Header="Deal Date" Width="Auto" IsFilterable="True" TextAlignment="Right" IsSortable="True" FilteringControlStyle="{StaticResource ReverseOrderOfItems_FilterControlStyle}">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Path=DealDate, StringFormat=dd/MM/yyyy}"></TextBlock>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

controls version: 2012.1.0326.1040

any advice kindly welcome
KR
Piotrek

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 01 Feb 2013, 12:44 PM
Hello,

I have tried to reproduce the problem using the pasted ControlTemplate. At first I were not able to run it due to the missing resources. For example the: reverseItemsSourceConverter. That is why I deleted it. Then I run it (adding the definitions for the other missing resources) and I were not able to reproduce the issue. Do you reproduce it if you remove your additional converter?

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Piotr
Top achievements
Rank 1
answered on 01 Feb 2013, 01:40 PM
firstly, please take mine apologize for extra resource i forgot to attache. 
This mistake and your tries point me right direction! Specially your remark about missing converter. 
it's issue's source.

Thank you!

Piotrek
0
Dimitrina
Telerik team
answered on 01 Feb 2013, 04:55 PM
Hi,

I am glad that you have resolved the issue yourself. 

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Piotr
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Piotr
Top achievements
Rank 1
Share this question
or