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

GridView CompositeFilterDescriptor no longer working

9 Answers 163 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Brandon
Top achievements
Rank 1
Brandon asked on 21 Feb 2011, 03:00 PM

Hoping someone can help me with this. I just upgraded my WinForms controls to version 2010.3.10.1215 from 2010.3.10.1109 and my composite filters have stopped working. They do not cause an exception or break anything else, it's as if they are completely ignored. Indidual filters work perfectly still, but they are insufficient to my needs. So... I'm checking with the community before posting a ticket. Example composite filter below. Thanks

  

CompositeFilterDescriptor

 

compositeFilter = new CompositeFilterDescriptor();

 

 

compositeFilter.FilterDescriptors.Add(

new FilterDescriptor("IsDeleted", FilterOperator.IsEqualTo, false));

 

 

compositeFilter.FilterDescriptors.Add(

new FilterDescriptor("FolderLocation", FilterOperator.IsEqualTo, selectedFolder));

 

 

compositeFilter.LogicalOperator =

FilterLogicalOperator.And;

 

 

 

rgvEmails.FilterDescriptors.Clear();

rgvEmails.FilterDescriptors.Add(compositeFilter);

 

 

 

9 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 22 Feb 2011, 11:16 AM
Hello Brandon,

I haven't been able to replicate your issue with the latest version. I added a composite filter at the end of my form load as per the documentation here and all the filters were honoured.

May I ask you to post a small sample that replicates the issue and I'll be happy to take a look at it for you
Thanks
Richard
0
Brandon
Top achievements
Rank 1
answered on 21 Mar 2011, 08:12 PM
Ok, been busy, but finally had a chance to test all this again. The code remained the same through the tests. First I upgraded to the newest version of the controls (2011.1.11.315) to see if that helped. It did not. So I proceeded to remove all versions of the WinForms controls and reinstall the old version (2010.3.10.1109). Result? Everything began working again. Whether Telerik knows it or not the new versions changed (broke?) something with the composite filtering.
0
Richard Slade
Top achievements
Rank 2
answered on 22 Mar 2011, 10:40 AM
Hello Brandon,

Please could you post a sample that demonstrates your issue, and I'll be happy to take a look.
Thanks
Richard
0
Brandon
Top achievements
Rank 1
answered on 23 Mar 2011, 05:09 PM
Ok, here's a small winforms project (VS 2008) that shows my issue. As an aside, it would be more convenient if Telerik would let us attach zip files instead of just pics.

The current referenced Telerik DLL's in the project were [2010.3.10.1109]. When I remove these references and add new ones to version [2011.1.11.315] the composite filters stop working. Any ideas would be great.

--- Form1.cs ---
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls.Data;
using Telerik.WinControls.UI;
  
namespace CompositeFilterTest
{
    public partial class Form1 : Form
    {
        private BindingList<ObjectData> localBindList = new BindingList<ObjectData>();
  
        public Form1()
        {
            InitializeComponent();
  
            LoadData();
        }
  
        private void LoadData()
        {
            ObjectData object1 = new ObjectData();
            object1.Folder = "FolderOne";
            object1.Title = "object One";
            object1.Date = DateTime.Now;
  
            ObjectData object2 = new ObjectData();
            object2.Folder = "FolderOne";
            object2.Title = "object Two";
            object2.Date = DateTime.Now.AddDays(-1);
  
            ObjectData object3 = new ObjectData();
            object3.Folder = "FolderTwo";
            object3.Title = "object Three";
            object3.Date = DateTime.Now.AddDays(-2);
  
            ObjectData object4 = new ObjectData();
            object4.Folder = "FolderTwo";
            object4.Title = "object Four";
            object4.Date = DateTime.Now.AddDays(-3);
  
            ObjectData object5 = new ObjectData();
            object5.Folder = "FolderTwo";
            object5.Title = "object Five";
            object5.Date = DateTime.Now.AddDays(-4);
  
            ObjectData object6 = new ObjectData();
            object6.Folder = "FolderThree";
            object6.Title = "object Six";
            object6.Date = DateTime.Now.AddDays(-5);
  
            ObjectData object7 = new ObjectData();
            object7.Folder = "FolderThree";
            object7.Title = "object Seven";
            object7.Date = DateTime.Now.AddDays(-6);
  
            ObjectData object8 = new ObjectData();
            object8.Folder = "SingleFilter";
            object8.Title = "object Eight";
            object8.Date = DateTime.Now.AddDays(-7);
            object8.IsActive = false;
  
            localBindList.Add(object1);
            localBindList.Add(object2);
            localBindList.Add(object3);
            localBindList.Add(object4);
            localBindList.Add(object5);
            localBindList.Add(object6);
            localBindList.Add(object7);
            localBindList.Add(object8);
  
            rgvObjects.DataSource = localBindList;
        }
  
        private void ChangeFolder(string folder)
        {
            if (folder == "SingleFilter")
            {
                FilterDescriptor filter = new FilterDescriptor("IsActive", FilterOperator.IsEqualTo, false);
  
                rgvObjects.FilterDescriptors.Clear();
                rgvObjects.FilterDescriptors.Add(filter);
            }
            else // Composite
            {
                CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
                compositeFilter.FilterDescriptors.Add(new FilterDescriptor("IsActive", FilterOperator.IsEqualTo, true));
                compositeFilter.FilterDescriptors.Add(new FilterDescriptor("Folder", FilterOperator.IsEqualTo, folder));
                compositeFilter.LogicalOperator = FilterLogicalOperator.And;
  
                rgvObjects.FilterDescriptors.Clear();
                rgvObjects.FilterDescriptors.Add(compositeFilter);
            }
        }
  
        private void btnCompOne_Click(object sender, EventArgs e)
        {
            ChangeFolder("FolderOne");
        }
  
        private void btnCompTwo_Click(object sender, EventArgs e)
        {
            ChangeFolder("FolderTwo");
        }
  
        private void btnCompThree_Click(object sender, EventArgs e)
        {
            ChangeFolder("FolderThree");
        }
  
        private void btnSingleFilter_Click(object sender, EventArgs e)
        {
            ChangeFolder("SingleFilter");
        }
    }
  
    public class ObjectData
    {
        private string _title;
        private DateTime _date;
        private string _folder;
        private bool _isActive;
  
        public ObjectData()
        {
            _isActive = true;
        }
  
        public string Title
        {
            get { return _title; }
            set
            {
                _title = value;
            }
        }
  
        public string Folder
        {
            get { return _folder; }
            set
            {
                _folder = value;
            }
        }
  
        public DateTime Date
        {
            get { return _date; }
            set
            {
                _date = value;
            }
        }
  
        public bool IsActive
        {
            get { return _isActive; }
            set
            {
                _isActive = value;
            }
        }
    }
}

--- Form1.Designer.cs ---
namespace CompositeFilterTest
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
  
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
  
        #region Windows Form Designer generated code
  
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn1 = new Telerik.WinControls.UI.GridViewTextBoxColumn();
            Telerik.WinControls.UI.GridViewDateTimeColumn gridViewDateTimeColumn1 = new Telerik.WinControls.UI.GridViewDateTimeColumn();
            Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn2 = new Telerik.WinControls.UI.GridViewTextBoxColumn();
            Telerik.WinControls.UI.GridViewCheckBoxColumn gridViewCheckBoxColumn1 = new Telerik.WinControls.UI.GridViewCheckBoxColumn();
            this.rgvObjects = new Telerik.WinControls.UI.RadGridView();
            this.btnCompOne = new System.Windows.Forms.Button();
            this.btnCompTwo = new System.Windows.Forms.Button();
            this.btnSingleFilter = new System.Windows.Forms.Button();
            this.btnCompThree = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.rgvObjects)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.rgvObjects.MasterTemplate)).BeginInit();
            this.SuspendLayout();
            // 
            // rgvObjects
            // 
            this.rgvObjects.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.rgvObjects.EnableFastScrolling = true;
            this.rgvObjects.Location = new System.Drawing.Point(0, 152);
            // 
            // rgvObjects
            // 
            this.rgvObjects.MasterTemplate.AllowAddNewRow = false;
            this.rgvObjects.MasterTemplate.AllowColumnHeaderContextMenu = false;
            this.rgvObjects.MasterTemplate.AllowColumnReorder = false;
            this.rgvObjects.MasterTemplate.AllowDragToGroup = false;
            this.rgvObjects.MasterTemplate.AllowEditRow = false;
            this.rgvObjects.MasterTemplate.AllowRowResize = false;
            this.rgvObjects.MasterTemplate.AutoGenerateColumns = false;
            this.rgvObjects.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
            gridViewTextBoxColumn1.AllowSort = false;
            gridViewTextBoxColumn1.FieldName = "Title";
            gridViewTextBoxColumn1.FormatString = "";
            gridViewTextBoxColumn1.HeaderText = "Title";
            gridViewTextBoxColumn1.HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            gridViewTextBoxColumn1.MinWidth = 50;
            gridViewTextBoxColumn1.Name = "Title";
            gridViewTextBoxColumn1.Width = 574;
            gridViewDateTimeColumn1.AllowSort = false;
            gridViewDateTimeColumn1.FieldName = "Date";
            gridViewDateTimeColumn1.Format = System.Windows.Forms.DateTimePickerFormat.Long;
            gridViewDateTimeColumn1.FormatString = "";
            gridViewDateTimeColumn1.HeaderText = "Date";
            gridViewDateTimeColumn1.HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            gridViewDateTimeColumn1.MaxWidth = 150;
            gridViewDateTimeColumn1.MinWidth = 150;
            gridViewDateTimeColumn1.Name = "Date";
            gridViewDateTimeColumn1.Width = 150;
            gridViewTextBoxColumn2.FieldName = "Folder";
            gridViewTextBoxColumn2.HeaderText = "";
            gridViewTextBoxColumn2.IsVisible = false;
            gridViewTextBoxColumn2.Name = "Folder";
            gridViewTextBoxColumn2.Width = 5;
            gridViewCheckBoxColumn1.FieldName = "IsActive";
            gridViewCheckBoxColumn1.HeaderText = "";
            gridViewCheckBoxColumn1.IsVisible = false;
            gridViewCheckBoxColumn1.Name = "IsActive";
            gridViewCheckBoxColumn1.Width = 20;
            this.rgvObjects.MasterTemplate.Columns.AddRange(new Telerik.WinControls.UI.GridViewDataColumn[] {
            gridViewTextBoxColumn1,
            gridViewDateTimeColumn1,
            gridViewTextBoxColumn2,
            gridViewCheckBoxColumn1});
            this.rgvObjects.MasterTemplate.EnableFiltering = true;
            this.rgvObjects.MasterTemplate.MultiSelect = true;
            this.rgvObjects.MasterTemplate.ShowFilteringRow = false;
            this.rgvObjects.MasterTemplate.ShowGroupedColumns = true;
            this.rgvObjects.MasterTemplate.ShowRowHeaderColumn = false;
            this.rgvObjects.Name = "rgvObjects";
            this.rgvObjects.ReadOnly = true;
            this.rgvObjects.ShowGroupPanel = false;
            this.rgvObjects.Size = new System.Drawing.Size(725, 266);
            this.rgvObjects.TabIndex = 0;
            this.rgvObjects.Text = "radGridView1";
            // 
            // btnCompOne
            // 
            this.btnCompOne.Location = new System.Drawing.Point(46, 27);
            this.btnCompOne.Name = "btnCompOne";
            this.btnCompOne.Size = new System.Drawing.Size(134, 23);
            this.btnCompOne.TabIndex = 1;
            this.btnCompOne.Tag = "";
            this.btnCompOne.Text = "Composite One";
            this.btnCompOne.UseVisualStyleBackColor = true;
            this.btnCompOne.Click += new System.EventHandler(this.btnCompOne_Click);
            // 
            // btnCompTwo
            // 
            this.btnCompTwo.Location = new System.Drawing.Point(46, 56);
            this.btnCompTwo.Name = "btnCompTwo";
            this.btnCompTwo.Size = new System.Drawing.Size(134, 23);
            this.btnCompTwo.TabIndex = 2;
            this.btnCompTwo.Tag = "";
            this.btnCompTwo.Text = "Composite Two";
            this.btnCompTwo.UseVisualStyleBackColor = true;
            this.btnCompTwo.Click += new System.EventHandler(this.btnCompTwo_Click);
            // 
            // btnSingleFilter
            // 
            this.btnSingleFilter.Location = new System.Drawing.Point(454, 56);
            this.btnSingleFilter.Name = "btnSingleFilter";
            this.btnSingleFilter.Size = new System.Drawing.Size(134, 23);
            this.btnSingleFilter.TabIndex = 3;
            this.btnSingleFilter.Tag = "";
            this.btnSingleFilter.Text = "Single Filter";
            this.btnSingleFilter.UseVisualStyleBackColor = true;
            this.btnSingleFilter.Click += new System.EventHandler(this.btnSingleFilter_Click);
            // 
            // btnCompThree
            // 
            this.btnCompThree.Location = new System.Drawing.Point(46, 85);
            this.btnCompThree.Name = "btnCompThree";
            this.btnCompThree.Size = new System.Drawing.Size(134, 23);
            this.btnCompThree.TabIndex = 4;
            this.btnCompThree.Tag = "";
            this.btnCompThree.Text = "Composite Three";
            this.btnCompThree.UseVisualStyleBackColor = true;
            this.btnCompThree.Click += new System.EventHandler(this.btnCompThree_Click);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(725, 418);
            this.Controls.Add(this.btnCompThree);
            this.Controls.Add(this.btnSingleFilter);
            this.Controls.Add(this.btnCompTwo);
            this.Controls.Add(this.btnCompOne);
            this.Controls.Add(this.rgvObjects);
            this.Name = "Form1";
            this.Text = "Composite Filter Test";
            ((System.ComponentModel.ISupportInitialize)(this.rgvObjects.MasterTemplate)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.rgvObjects)).EndInit();
            this.ResumeLayout(false);
  
        }
  
        #endregion
  
        private Telerik.WinControls.UI.RadGridView rgvObjects;
        private System.Windows.Forms.Button btnCompOne;
        private System.Windows.Forms.Button btnCompTwo;
        private System.Windows.Forms.Button btnSingleFilter;
        private System.Windows.Forms.Button btnCompThree;
    }
}
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 23 Mar 2011, 06:43 PM
Hi Brandon,

Ok, I have this working for you. I find it difficult to understand how this hasn't been reported before but at least I seem to have a workaround for you.

When you add more than one filter descriptor to the composite filter then the property name ends up as null of the coposite filter and the FilterExpressionChanged event never fires. By adding a property name to the Composite Filter that is one of the property names of properties that you are filtering, this now seems to work fine. I have altered your code (note: namespace removed) to show the FilterExpressionChanged event and I have added in the property name which fixes the issue.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls.Data;
using Telerik.WinControls.UI;
  
  
    public partial class Form1 : Form
    {
        private BindingList<ObjectData> localBindList = new BindingList<ObjectData>();
  
        public Form1()
        {
            InitializeComponent();
  
            this.rgvObjects.EnableFiltering = true;
            this.rgvObjects.ShowFilteringRow = true;
  
            LoadData();
        }
  
        private void LoadData()
        {
            ObjectData object1 = new ObjectData();
            object1.Folder = "FolderOne";
            object1.Title = "object One";
            object1.Date = DateTime.Now;
  
            ObjectData object2 = new ObjectData();
            object2.Folder = "FolderOne";
            object2.Title = "object Two";
            object2.Date = DateTime.Now.AddDays(-1);
  
            ObjectData object3 = new ObjectData();
            object3.Folder = "FolderTwo";
            object3.Title = "object Three";
            object3.Date = DateTime.Now.AddDays(-2);
  
            ObjectData object4 = new ObjectData();
            object4.Folder = "FolderTwo";
            object4.Title = "object Four";
            object4.Date = DateTime.Now.AddDays(-3);
  
            ObjectData object5 = new ObjectData();
            object5.Folder = "FolderTwo";
            object5.Title = "object Five";
            object5.Date = DateTime.Now.AddDays(-4);
  
            ObjectData object6 = new ObjectData();
            object6.Folder = "FolderThree";
            object6.Title = "object Six";
            object6.Date = DateTime.Now.AddDays(-5);
  
            ObjectData object7 = new ObjectData();
            object7.Folder = "FolderThree";
            object7.Title = "object Seven";
            object7.Date = DateTime.Now.AddDays(-6);
  
            ObjectData object8 = new ObjectData();
            object8.Folder = "SingleFilter";
            object8.Title = "object Eight";
            object8.Date = DateTime.Now.AddDays(-7);
            object8.IsActive = false;
  
            localBindList.Add(object1);
            localBindList.Add(object2);
            localBindList.Add(object3);
            localBindList.Add(object4);
            localBindList.Add(object5);
            localBindList.Add(object6);
            localBindList.Add(object7);
            localBindList.Add(object8);
  
            rgvObjects.DataSource = localBindList;
  
        }
  
        private void ChangeFolder(string folder)
        {
            if (folder == "SingleFilter")
            {
                FilterDescriptor filter = new FilterDescriptor("IsActive", FilterOperator.IsEqualTo, false);
  
                rgvObjects.FilterDescriptors.Clear();
                rgvObjects.FilterDescriptors.Add(filter);
            }
            else // Composite 
            {
                CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
                compositeFilter.FilterDescriptors.Add(new FilterDescriptor("IsActive", FilterOperator.IsEqualTo, true));
                compositeFilter.FilterDescriptors.Add(new FilterDescriptor("Folder", FilterOperator.IsEqualTo, folder));
                compositeFilter.LogicalOperator = FilterLogicalOperator.And;
                compositeFilter.PropertyName = "Folder"; // needs one of the property names in the descriptors
                rgvObjects.FilterDescriptors.Clear();
                rgvObjects.FilterDescriptors.Add(compositeFilter);
            }
        }
  
        private void btnCompOne_Click(object sender, EventArgs e)
        {
            ChangeFolder("FolderOne");
        }
  
        private void btnCompTwo_Click(object sender, EventArgs e)
        {
            ChangeFolder("FolderTwo");
        }
  
        private void btnCompThree_Click(object sender, EventArgs e)
        {
            ChangeFolder("FolderThree");
        }
  
        private void btnSingleFilter_Click(object sender, EventArgs e)
        {
            ChangeFolder("SingleFilter");
        }
  
        private void rgvObjects_FilterExpressionChanged(object sender, FilterExpressionChangedEventArgs e)
        {
            MessageBox.Show(e.FilterExpression.ToString());
        }
    }
  
    public class ObjectData
    {
        private string _title;
        private DateTime _date;
        private string _folder;
        private bool _isActive;
  
        public ObjectData()
        {
            _isActive = true;
        }
  
        public string Title
        {
            get { return _title; }
            set
            {
                _title = value;
            }
        }
  
        public string Folder
        {
            get { return _folder; }
            set
            {
                _folder = value;
            }
        }
  
        public DateTime Date
        {
            get { return _date; }
            set
            {
                _date = value;
            }
        }
  
        public bool IsActive
        {
            get { return _isActive; }
            set
            {
                _isActive = value;
            }
        }
    }


Please let me know if this helps, and indeed if there is anything else you need. It's propbably worth opening a support ticket for this. If you do, please reference this forum thread so Telerik can keep track of all discussion. If you want me to do this for you and feed back the response, just let me know

Hope that helps
Richard
0
Brandon
Top achievements
Rank 1
answered on 23 Mar 2011, 09:26 PM
Thanks a million, Richard! I went ahead and submitted the ticket (Click here) with a link back to this forum and credit to you for finding the source of the issue. Keep up the great work!
0
Richard Slade
Top achievements
Rank 2
answered on 23 Mar 2011, 10:19 PM
Hi,
I'm really glad that helped. May I ask that you mark as answer so that others looking for a solution can quickly find teh answer too.
Let me know if there's anything else
Richard
0
Jason
Top achievements
Rank 1
answered on 10 May 2011, 06:29 PM
Thanks Richard, I was having the same issue and this resolved it for me.
0
Christ
Top achievements
Rank 2
answered on 31 Aug 2011, 02:41 PM
Hi all,

I had the same problem but could only solve it by clearing the FilterDescriptors collection in the FilterChanging event:

private bool clearingFilters = false;
private void GridView_FilterChanging(object sender, GridViewCollectionChangingEventArgs e)
{
  // Clear the current filter
  if (!clearingFilters)
  {
    clearingFilters = true;
    workQueueGridView.FilterDescriptors.Clear();
    clearingFilters = false;
  }
}


Hope that makes sense,

Christ
Tags
GridView
Asked by
Brandon
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Brandon
Top achievements
Rank 1
Jason
Top achievements
Rank 1
Christ
Top achievements
Rank 2
Share this question
or