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

Auto apply filter value

5 Answers 97 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 03 Aug 2011, 02:08 PM
Hi,
I'm using the DataFilter control placed in a ToolBar (in unbound mode (if relevant)).
<ToolBarTray DockPanel.Dock="Top" Name="toolBarTrayTop">
   <!-- Filter Toolbar   -->
   <ToolBar Height="26" Name="toolBarFilter" Visibility="{Binding Path=ToolsFilterVisibility}">
      <Button Name="btnFilterRefresh" Command="{Binding Path=FilterRefreshCommand}" Style="{StaticResource BtnRefreshNeededIndication}">
      </Button>
   </ToolBar>
   <!-- FilterSettings Toolbar   -->
   <ToolBar Name="toolBarFilterSettings" Visibility="{Binding Path=ToolsFilterSettingsVisibility}">
      <telerik:RadDataFilter Name="radDataFilterMain" local:DataFilterMarkupExtension.FilterItems="{Binding DefaultFilterItems}" local:DataFilterMarkupExtension.FilterDefinitions="{Binding DefaultFilterDescriptors}"/>
   </ToolBar>
</ToolBarTray>

I need to know when a filter definition has been changed, therefore I have registered the "CollectionChanged" and "ItemChanged" events on the FilterDescriptors collection. This is works fine, with one exception. If the user only changes a filter value, the filter definition is not changing until he hits enter of click a other control inside the DataFilter. But in my case he could click on a separate "Refresh' button inside the ToolBar. In this case the the "FilterDescriptors" do not change (no focus change as the value control still shows the focus border) and so the filter is showing something different than the "FilterDescriptors" are reporting.
My question is is there a know workaround for such a situation?

Many thanks
Thomas

5 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 03 Aug 2011, 02:36 PM
Hello Thomas,

Can you send me a small demo project that demonstrates this behavior. It is weird how the user can click another button and the focus still stays in the RadDataFilter. I will debug it once I have it.

I am looking forward to hearing from you.

Regards,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Thomas
Top achievements
Rank 1
answered on 03 Aug 2011, 04:03 PM
Hi Ross,

I made a simple example as possible. To reproduce the behaviour just click '+' to add a filter definition, type in a value and click the button "Press me and.." And you will see that the update count is 1 (from '+') but not from changing the value and the focus rectangle is still shown on the value control.
I hope this helps.

Regards
Thomas

<Window x:Class="DataFilter.MainWindow"
        Title="MainWindow" Height="350" Width="783" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <Grid>
      <StackPanel Name="stackPanel1">
          
         <ToolBarTray Name="toolBarTray1">
            <ToolBar Name="toolBar1">
               <Button Content="Press me and the filter will not change" Name="button1" />
            </ToolBar>
            <ToolBar Name="toolBar2">
               <telerik:RadDataFilter Name="radDataFilter1" />
            </ToolBar>
         </ToolBarTray>
         <Label Content="Filter Change count" Height="28" Name="label1" />
      </StackPanel>
   </Grid>
</Window>

and code behind

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Controls.Data.DataFilter;
 
namespace DataFilter {
    
   /// <summary>
   /// Interaktionslogik für MainWindow.xaml
   /// </summary>
   public partial class MainWindow : Window {
      private int _ChangeCount = 0;
 
      public MainWindow() {
         InitializeComponent();
 
         radDataFilter1.ItemPropertyDefinitions.Add(new ItemPropertyDefinition("Col1", typeof(string), "Col1"));
         radDataFilter1.ItemPropertyDefinitions.Add(new ItemPropertyDefinition("Col2", typeof(string), "Col2"));
         radDataFilter1.ItemPropertyDefinitions.Add(new ItemPropertyDefinition("Col3", typeof(string), "Col3"));
         radDataFilter1.ItemPropertyDefinitions.Add(new ItemPropertyDefinition("Col4", typeof(string), "Col4"));
 
         radDataFilter1.FilterDescriptors.CollectionChanged +=new System.Collections.Specialized.NotifyCollectionChangedEventHandler(FilterDescriptors_CollectionChanged);
         radDataFilter1.FilterDescriptors.ItemChanged +=new EventHandler<Telerik.Windows.Data.ItemChangedEventArgs<Telerik.Windows.Data.IFilterDescriptor>>(FilterDescriptors_ItemChanged);
 
          
      }
 
      void FilterDescriptors_ItemChanged(object sender, Telerik.Windows.Data.ItemChangedEventArgs<Telerik.Windows.Data.IFilterDescriptor> e) {
         _ChangeCount++;
         label1.Content = _ChangeCount;
      }
 
      void FilterDescriptors_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) {
         _ChangeCount++;
         label1.Content = _ChangeCount;
      }
   }
}

0
Rossen Hristov
Telerik team
answered on 03 Aug 2011, 04:07 PM
Hello Thomas,

Why don't you zip and attach the actual project. You have it already made. Simply zip it and send it to me. 

Thanks.

Best wishes,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Thomas
Top achievements
Rank 1
answered on 03 Aug 2011, 04:50 PM
Hi Ross,

I would like to, but I don't have your Address.

Regards
Thomas
0
Vlad
Telerik team
answered on 04 Aug 2011, 07:23 AM
Hi Thomas,

 You can open support ticket.

Best wishes,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
DataFilter
Asked by
Thomas
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Thomas
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or