popup close on filter row click

9 posts, 0 answers
  1. Eastern
    Eastern avatar
    43 posts
    Member since:
    Sep 2010

    Posted 04 Oct 2011 Link to this post

    Hello all,

    in 2011 Q1 winforms, i have a user control inherited from RadMultiColumnComboBox, and the filter row for inner radgrid is enabled.
    problem is when i click on the filter row, the popup close ! so i cannot get focus on the filter row textbox to type the filtering text .

    would you please tell me why this is occuring and how can i solve it ?

    Thank you,
  2. Boris
    Boris avatar
    3 posts
    Member since:
    Sep 2010

    Posted 01 Nov 2011 Link to this post

    Hi,
    I have the same problem.
    Do you have any solution for this problem?

    Thank you!
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Brad
    Brad avatar
    20 posts
    Member since:
    Apr 2010

    Posted 09 Dec 2011 Link to this post

    Hi, I have solved the problem with this code, when using a Form Level Multi Column Combo Box:
    /// <summary>
    /// Cancel MultiColumnComboBox Close on  heaader or filter field click
    /// </summary>
    private void MultiColumnComboBox_DropDownClosing(object sender, RadPopupClosingEventArgs args)
    {
        if ((sender as RadMultiColumnComboBox).SelectedIndex == -1)
        {
            args.Cancel = true;
        }
    }

    When using the  Multi Column Combo Box  Column in a GridView I use this code:

    /// <summary>
    /// Cancel MultiColumnComboBox Column Close on  header or filter field click
    /// </summary>
    private void radMultiColumnComboBox_Generic_PopupClosing(object sender, RadPopupClosingEventArgs args)
    {
        if ((sender as RadMultiColumnComboBoxElement).SelectedIndex == -1)
        {
            if ((sender as RadMultiColumnComboBoxElement).Rows.Count > 0)
                args.Cancel = true;
        }         
    }



  5. Ofer
    Ofer avatar
    19 posts
    Member since:
    Jan 2012

    Posted 31 Jan 2012 Link to this post

    Hi Brand,
    I used your first code and it's good. thanks.
    But i wander way the don't fix it in Telerik.
    Any way the way to close the grid without selecting  any row is to click the combo itself.
    The problem is that if i click the filtering row i can't close the grid without selecting.
    Do you have solution for this?
    Thanks'
    Ofer. 
  6. Brad
    Brad avatar
    20 posts
    Member since:
    Apr 2010

    Posted 20 Feb 2012 Link to this post

    The problem is that if i click the filtering row i can't close the grid without selecting. Do you have solution for this? 

    I do not have a solution for this. This column is a required field in my program so it works well for me to force a selection. Without the extra check for some "possible selection" rows in the filtered RadGridView MultiColumnComboBox, user clicks could throw an exception that I couldn't handle and would crash my program.
  7. Felix
    Felix avatar
    5 posts
    Member since:
    Nov 2012

    Posted 20 Oct 2013 Link to this post

    I've worked on a simple way of enabling/disabling filtering in RadMultiColumnComboBox.

    It's an extension method.

    The usage is
    theCombo.Filtering(true); //Enabling
    theCombo.Filtering(false); //Disabling

    It's not bug free, but as far as I've tested it works in a nice way.

    When filtering is enabled, a filter row will appear when clicking on the RadMultiColumnComboBox. Many filters may be written once (multi column filtering). After the popup is closed, all the filters will be erased.

    When clicking outside of the popup, or clicking on a row (not the filter one), the popup will be automatically closed.

    And the extension method code
    internal static class ExtensionsRadMultiColumnComboBox
    {
            public static void Filtering(this RadMultiColumnComboBox combo, bool enable)
            {
                if (enable)
                {
                    if (!combo.EditorControl.EnableFiltering)
                    {
                        combo.DropDownClosing += RadMultiColumnComboBoxDropDownClosing;
     
                        var multiColumnComboBoxElement = combo.MultiColumnComboBoxElement;
                        multiColumnComboBoxElement.EditorControl.EnableFiltering = true;
                        multiColumnComboBoxElement.EditorControl.ShowFilteringRow = true;
                        multiColumnComboBoxElement.EditorControl.FilterChanging +=
                            RadMultiColumnComboBoxEditorControlFilterChanging;
                    }
                }
                else
                {
                    if (combo.EditorControl.EnableFiltering)
                    {
                        combo.DropDownClosing -= RadMultiColumnComboBoxDropDownClosing;
     
                        var multiColumnComboBoxElement = combo.MultiColumnComboBoxElement;
                        multiColumnComboBoxElement.EditorControl.EnableFiltering = false;
                        multiColumnComboBoxElement.EditorControl.ShowFilteringRow = false;
                        multiColumnComboBoxElement.EditorControl.FilterChanging -=
                            RadMultiColumnComboBoxEditorControlFilterChanging;
                    }
                }
            }
     
            private static void RadMultiColumnComboBoxEditorControlFilterChanging(object sender,
                GridViewCollectionChangingEventArgs e)
            {
                var multiColumnComboGridView = sender as MultiColumnComboGridView;
                if (multiColumnComboGridView == null) return;
                if (multiColumnComboGridView.Parent == null) return;
                var radPopupControlBase = multiColumnComboGridView.Parent as MultiColumnComboPopupForm;
                if (radPopupControlBase == null) return;
                if (!radPopupControlBase.IsDisplayed) return;
                if (e.OldItems == null) return;
                if (e.OldItems.Count == 0) return;
                var filterDescriptor = e.OldItems[0] as FilterDescriptor;
                if (filterDescriptor == null) return;
                var grid = multiColumnComboGridView;
                var currentRow = grid.CurrentRow;
                if (currentRow.RowElementType != typeof (GridFilterRowElement)) return;
                var value = currentRow.Cells[filterDescriptor.PropertyName].Value ?? string.Empty;
                if (value == null) return;
                string activeEditorString = null;
                if (grid.ActiveEditor != null)
                {
                    var activeEditorValue = grid.ActiveEditor.Value ?? string.Empty;
                    activeEditorString = activeEditorValue.ToString();
                }
                if (e.NewValue == null && value.ToString() != string.Empty &&
                    !(activeEditorString != null && activeEditorString == string.Empty &&
                      grid.CurrentColumn.Name == filterDescriptor.PropertyName))
                    e.Cancel = true;
            }
     
            private static void RadMultiColumnComboBoxDropDownClosing(object sender, RadPopupClosingEventArgs args)
            {
                var radMultiColumnComboBox = sender as RadMultiColumnComboBox;
                if (radMultiColumnComboBox == null) return;
                var popupForm = radMultiColumnComboBox.MultiColumnComboBoxElement.PopupForm;
                var editorControl = radMultiColumnComboBox.MultiColumnComboBoxElement.EditorControl;
                MultiColumnComboBoxDropDownClosingHandler(popupForm, editorControl, args);
            }
     
            private static void MultiColumnComboBoxDropDownClosingHandler(RadPopupControlBase popupForm,
                RadGridView editorControl, RadPopupClosingEventArgs args)
            {
                var mousePosition = Control.MousePosition;
                var xIn = mousePosition.X >= popupForm.Location.X &&
                          mousePosition.X <= popupForm.Location.X + popupForm.Size.Width;
                var yIn = mousePosition.Y >= popupForm.Location.Y &&
                          mousePosition.Y <= popupForm.Location.Y + popupForm.Size.Height;
                if (editorControl.CurrentRow.Index == -1 && xIn && yIn)
                {
                    args.Cancel = true;
                }
                else
                {
                    if (editorControl.ActiveEditor != null)
                    {
                        editorControl.ActiveEditor.EndEdit();
                    }
                    editorControl.FilterChanging -= RadMultiColumnComboBoxEditorControlFilterChanging;
                    foreach (var column in editorControl.Columns)
                    {
                        column.FilterDescriptor = null;
                    }
                    editorControl.FilterChanging += RadMultiColumnComboBoxEditorControlFilterChanging;
                }
            }
    }

    Hope this helps someone!
  8. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 24 Oct 2013 Link to this post

    Hello Felix,

    Thank you for sharing your code with the community. I am sure someone will benefit from it.

    I have updated your Telerik points for the contribution.

    Greetings,
    Desislava
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  9. Mahdi
    Mahdi avatar
    2 posts
    Member since:
    Oct 2016

    Posted 05 Oct in reply to Felix Link to this post

    hi,

    how to use your code, can you explain more?

    thanks

  10. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 05 Oct Link to this post

    Hello Mahdi,

    Thank you for writing.  

    The provided code snippet by Felix demonstrates how to create an extension Filtering method for the RadMultiColumnComboBox. It enables the filtering row in the popup grid. I have attached a sample project for your reference.

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready