Completed
Last Updated: 15 Jun 2018 13:51 by Dimitar
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 04 May 2018 06:22
Category: GridView
Type: Bug Report
1
FIX. RadGridView - visible rows are not checked in the filter popup of the Excel-like filtering
To reproduce: set Excel-like filter according to the online documentation: https://docs.telerik.com/devtools/winforms/gridview/filtering/setting-filters-programmatically-(composite-descriptors)

            this.radGridView1.DataSource = this.productsBindingSource;
            this.productsTableAdapter.Fill(this.nwindDataSet.Products);

            this.radGridView1.EnableFiltering = true;
            this.radGridView1.ShowHeaderCellButtons = true;
            
            var filterDescriptor = new FilterDescriptor();
            filterDescriptor.PropertyName = "UnitsInStock";
            filterDescriptor.Value = 101;
            filterDescriptor.Operator = FilterOperator.IsEqualTo;

            var filterDescriptor2 = new FilterDescriptor();
            filterDescriptor2.PropertyName = "UnitsInStock";
            filterDescriptor2.Value = 104;
            filterDescriptor2.Operator = FilterOperator.IsEqualTo;
            var cfd = new CompositeFilterDescriptor();
            cfd.LogicalOperator = FilterLogicalOperator.Or;
            cfd.FilterDescriptors.Add(filterDescriptor);
            cfd.FilterDescriptors.Add(filterDescriptor2);
            cfd.IsFilterEditor = true;
            this.radGridView1.FilterDescriptors.Add(cfd);
            this.radGridView1.MasterTemplate.ExcelFilteredColumns.Add(this.radGridView1.Columns["UnitsInStock"]);

You will notice that the filter popup contains all possible values for this column which is OK, but none of the nodes is checked. It is necessary the visible rows to be checked. 

Workaround: check the nodes programmatically when the popup is shown:

        private void radGridView1_FilterPopupInitialized(object sender, Telerik.WinControls.UI.FilterPopupInitializedEventArgs e)
        {
            RadListFilterPopup popup = e.FilterPopup as RadListFilterPopup;
            if (popup!=null)
            {
                popup.Tag = e.Column.Name;
               popup.PopupOpened-=popup_PopupOpened;
                popup.PopupOpened+=popup_PopupOpened;
            }
        }

        private void popup_PopupOpened(object sender, EventArgs args)
        {
           RadListFilterPopup popup = sender as RadListFilterPopup;

           foreach (GridViewRowInfo row in this.radGridView1.ChildRows)
           {
             RadTreeNode node=   popup.MenuTreeElement.TreeView.FindNodes(row.Cells[popup.Tag+""].Value.ToString()).FirstOrDefault();
             if (node!=null)
             {
                 node.Checked = true;
             }
           }
        }
0 comments