Having problem with compositeFilter.LogicalOperator

1 posts, 0 answers
  1. Snype
    Snype avatar
    9 posts
    Member since:
    Jan 2012

    Posted 06 Mar 2012 Link to this post


    I have created a custom filter control. In The filter control I am displaying a list of available options for the associated column.
    The column may have a values separated by comma or newline.
    For Example a Column value is "Electrical, Mechanical". The filter control has options listed as "Electrical" "Mechanica", "HVAC"..etc. If I select "Electrical" and "Mechanical" in the custom filter screen and click Filter, It should display me all the rows that contains "Electrical" or "Mechanical".

    To achive this I have used a composite filter and set the logical operator to FilterCompositionLogicalOperator.Or
    But it stil gives me the resulting rows where the column contains "Electrical" AND "Mechanical". Is there any way I could make it to display rows contaings data as "Electrical" OR "Mechanical".

    Data Type for the source column is string.

    Please help.
    Thanks in advance

    XML file for the Cusom Filter Control
                    Text="Show Attributes of Discipline" />
                <StackPanel Orientation="Horizontal"
                        Width="80" />
                        Width="80" />
    .CS file portion for the filter control is as below:
    public DisciplineFilterCtrl()
            private void CreateListBoxWithCheckBox(ObservableCollection<DisciplineWrapper> list)        {
                List<ListBoxItem> listBoxItem = new List<ListBoxItem>();
                foreach (DisciplineWrapper item in list)
                    if (item.Id != Guid.Empty && !item.Deleted)
                        ListBoxItem tempItem = new ListBoxItem();
                        CheckBox m_oCheckBox = new CheckBox();
                        m_oCheckBox.Content = item.Name;
                        m_oCheckBox.Tag = item;
                        tempItem.Content = m_oCheckBox;
                m_oDisciplines.ItemsSource = listBoxItem;
     private CompositeFilterDescriptor compositeFilter;
     private Telerik.Windows.Controls.GridViewBoundColumnBase column;
     private Telerik.Windows.Data.FilterDescriptor[] DisciplineFilter;
    private void CreateFilters()
                compositeFilter = new CompositeFilterDescriptor();
                //compositeFilter.LogicalOperator = FilterCompositionLogicalOperator.Or;
                int count = MetaDataCache.Cache.Disciplines.Count;
                string dataMember = this.column.DataMemberBinding.Path.Path;
                DisciplineFilter = new FilterDescriptor[count];
                for (int i = 0; i < count; i++)
                    this.DisciplineFilter[i] = new Telerik.Windows.Data.FilterDescriptor(dataMember
                             , Telerik.Windows.Data.FilterOperator.Contains
                             , null);
                compositeFilter.LogicalOperator = FilterCompositionLogicalOperator.Or;
            public void Prepare(Telerik.Windows.Controls.GridViewBoundColumnBase column)
                this.column = column as Telerik.Windows.Controls.GridViewBoundColumnBase;
                if (this.column == null)
                if (this.compositeFilter == null)
            private void FilterRecord()
               // this.compositeFilter.FilterDescriptors.Clear();
                int i = 0;
                List<ListBoxItem> listItems = this.m_oDisciplines.ItemsSource as List<ListBoxItem>;
                if (null != listItems)
                    foreach (var item in listItems)
                        CheckBox m_oCheckBox = item.Content as CheckBox;
                        if (null != m_oCheckBox && m_oCheckBox.IsChecked.Value)
                            this.DisciplineFilter[i].Value = m_oCheckBox.Content;
     private void m_oFilterButton_Click(object sender, RoutedEventArgs e)
                this.IsActive = true;

Back to Top