GridViewMultiComboBoxColumn with ShowFilteringRow

17 posts, 1 answers
  1. Gabriel
    Gabriel avatar
    4 posts
    Member since:
    Jul 2011

    Posted 16 Aug 2018 Link to this post

    I would like to use the filtering row of GridView of a GridViewMultiComboBoxColumn. I have made it show up with the code:

     

    editor.EditorControl.EnableFiltering = true;
    editor.EditorControl.ShowFilteringRow = true;

     

    This makes the row appear. However, upon clicking the filtering row the drop-down GridView immediately disappears. How can I make the GridView remain ONLY when typing into the filter row?

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3991 posts

    Posted 17 Aug 2018 Link to this post

    Hello, Gabriel,      

    In order to keep the popup opened while the filtering row is active, you can cancel the DropDownClosing event as follows:
    private void radMultiColumnComboBox1_DropDownClosing(object sender, Telerik.WinControls.UI.RadPopupClosingEventArgs args)
    {
        bool shouldCancel = this.radMultiColumnComboBox1.EditorControl.CurrentRow == this.radMultiColumnComboBox1.EditorControl.MasterView.TableFilteringRow;
        args.Cancel = shouldCancel;
    }

    I hope this information helps. If you have any additional questions, please let me know.  
     
    Regards,
    Dess
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Gabriel
    Gabriel avatar
    4 posts
    Member since:
    Jul 2011

    Posted 17 Aug 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    In order to keep the popup opened while the filtering row is active, you can cancel the DropDownClosing event as follows:

     

    I see that DropDownClosing event is on the RadMultiColumnComboBox class. Can you help me go from GridViewMultiComboBoxColumn or RadMultiColumnComboBoxElement to its RadMultiColumnComboBox? I must be missing something obvious.

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3991 posts

    Posted 20 Aug 2018 Link to this post

    Hello, Gabriel,      

    In order to access the RadMultiColumnComboBoxElement in RadGridView you can handle the CellEditorInitialized event as follows:

    private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
    {
        RadMultiColumnComboBoxElement mccb = e.ActiveEditor as RadMultiColumnComboBoxElement;
        if (mccb != null)
        {
            mccb.EditorControl.ShowFilteringRow = true;
            mccb.EditorControl.EnableFiltering = true;
            mccb.PopupClosing -= mccb_PopupClosing;
            mccb.PopupClosing += mccb_PopupClosing;
        }
    }
     
    private void mccb_PopupClosing(object sender, RadPopupClosingEventArgs args)
    {
        RadMultiColumnComboBoxElement mccb = sender as RadMultiColumnComboBoxElement;
        bool shouldCancel = mccb.EditorControl.CurrentRow == mccb.EditorControl.MasterView.TableFilteringRow;
        args.Cancel = shouldCancel;
    }

    I hope this information helps. If you have any additional questions, please let me know.  
     
    Regards,
    Dess
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  5. Gabriel
    Gabriel avatar
    4 posts
    Member since:
    Jul 2011

    Posted 20 Aug 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Hello Dess, this solution works but exposes an app-closing bug in Telerik. Steps to reproduce:

    With grid as previously discussed, open drop down menu of GridViewMultiComboBoxColumn.

    Click on filter row of drop down grid. The filter row does not cause the drop down to close, as intended.

    Click outside the drop down, such as another cell of the main grid or a different control entirely. The drop down still remains open even though it has lost focus.

    Click another UI element again, and application crashes completely due to the following error:

    Description: The process was terminated due to an unhandled exception.
    Exception Info: System.NullReferenceException
      at Telerik.WinControls.UI.MultiColumnComboPopupForm.CanClosePopup(Telerik.WinControls.UI.RadPopupCloseReason)
      at Telerik.WinControls.UI.PopupManager.OnMouseDown(System.Drawing.Point)
      at Telerik.WinControls.UI.PopupManager.Telerik.WinControls.IMessageListener.PreviewMessage(System.Windows.Forms.Message ByRef)
      at Telerik.WinControls.RadMessageFilter.NotifyGetMessageEvent(System.Windows.Forms.Message ByRef)
      at Telerik.WinControls.RadMessageFilter.GetMessageHookProc(Int32, IntPtr, IntPtr)

    Seems like a bug in the latest Telerik code to me. I'm trying to figure out what combination of checks inside of the DropDownClosing might detect when the user is no longer interacting with the drop down, but am having difficulty. Any additional help would be appreciated.

     

  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3991 posts

    Posted 21 Aug 2018 Link to this post

    Hello, Gabriel,      
     
    I have followed the described steps and replicated the problem. The current condition in the DropDownClosing event checks only whether the filter row is current in the popup. When you click another cell from the main grid, the condition is met and as a result the DropDownClosing event is canceled. It is necessary to extend the condition and check whether the popup contains the mouse. Here is demonstrated a sample code snippet. Note that this is just a sample solution and it may not cover all possible cases. Feel free to modify it in a way which suits your requirement best:

    private void mccb_PopupClosing(object sender, RadPopupClosingEventArgs args)
    {
        RadMultiColumnComboBoxElement mccb = sender as RadMultiColumnComboBoxElement;
        bool shouldCancel = mccb.EditorControl.CurrentRow == mccb.EditorControl.MasterView.TableFilteringRow;
        bool containsMouse = ((MultiColumnComboPopupForm)mccb.EditorControl.Parent).Bounds.Contains(Cursor.Position);
        if (shouldCancel == true && containsMouse)
        {
            args.Cancel = true;
        }
        else
        {
            args.Cancel = false;
        }
    }

    I hope this information helps. If you have any additional questions, please let me know.  
     
    Regards,
    Dess
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  7. Gabriel
    Gabriel avatar
    4 posts
    Member since:
    Jul 2011

    Posted 24 Aug 2018 Link to this post

    Hi Tess, I have this working now. Thank you for your help. I did want to point out two more bugs related to this that I hope your dev team can address in the future.

    #1 When the drop down grid is exposed and the user clicks on the filter row, the drop down's IndexChanged event is fired. It is not fired again when the user actually selects a row from the drop down grid. This means events that are supposed to occur after selection are not triggered.

    #2 The filter icons on each column of the filter row, which I believe are supposed to let the user choose between Contains/Starts With/etc., do not function with MultiComboBox. Not sure if there's a way to hide them.

    These bugs are not impediments for me at this time. Thanks again.

  8. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3991 posts

    Posted 28 Aug 2018 Link to this post

    Hello, Gabriel,        
     
    Note that by design, RadMultiColumnComboBox is not expected to show the filter row. In order to detect when the selected row is changed I would recommend you to subscribe to the RadMultiColumnComboBoxElement.EditorControl.CurrentRowChanged:

    private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
    {
        RadMultiColumnComboBoxElement mccb = e.ActiveEditor as RadMultiColumnComboBoxElement;
        if (mccb != null)
        {
            mccb.EditorControl.ShowFilteringRow = true;
            mccb.EditorControl.EnableFiltering = true;
            mccb.PopupClosing -= mccb_PopupClosing;
            mccb.PopupClosing += mccb_PopupClosing;
     
            mccb.EditorControl.CurrentRowChanged-=EditorControl_CurrentRowChanged;
            mccb.EditorControl.CurrentRowChanged+=EditorControl_CurrentRowChanged;
        }
    }
     
    private void EditorControl_CurrentRowChanged(object sender, CurrentRowChangedEventArgs e)
    {
        if (e.CurrentRow==null)
        {
            return;
        }
        Console.WriteLine(e.CurrentRow.Index);
    }

    As to the filter icons in the popup grid, note that the MultiColumnComboPopupForm which hosts the grid doesn't allow showing the context menu inside the popup grid. You can hide the filter buttons by using the ViewCellFormatting event:

    private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
    {
        RadMultiColumnComboBoxElement mccb = e.ActiveEditor as RadMultiColumnComboBoxElement;
        if (mccb != null)
        {
            mccb.EditorControl.ShowFilteringRow = true;
            mccb.EditorControl.EnableFiltering = true;
     
            mccb.EditorControl.ViewCellFormatting-=EditorControl_ViewCellFormatting;
            mccb.EditorControl.ViewCellFormatting+=EditorControl_ViewCellFormatting;
        }
    }
     
    private void EditorControl_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        GridFilterCellElement filterCell = e.CellElement as GridFilterCellElement;
        if (filterCell!=null)
        {
            filterCell.FilterButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
        }
    }

    I hope this information helps. If you have any additional questions, please let me know.  
     
    Regards,
    Dess
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  9. Cesar
    Cesar avatar
    16 posts
    Member since:
    May 2019

    Posted 25 Jun in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Is it possible to get this code in VB.NET?
  10. Cesar
    Cesar avatar
    16 posts
    Member since:
    May 2019

    Posted 25 Jun in reply to Cesar Link to this post

    Is it possible to get this code in VB.Net Please?

    private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
    {
        RadMultiColumnComboBoxElement mccb = e.ActiveEditor as RadMultiColumnComboBoxElement;
        if (mccb != null)
        {
            mccb.EditorControl.ShowFilteringRow = true;
            mccb.EditorControl.EnableFiltering = true;

            mccb.EditorControl.ViewCellFormatting-=EditorControl_ViewCellFormatting;
            mccb.EditorControl.ViewCellFormatting+=EditorControl_ViewCellFormatting;
        }
    }

    private void EditorControl_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        GridFilterCellElement filterCell = e.CellElement as GridFilterCellElement;
        if (filterCell!=null)
        {
            filterCell.FilterButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
        }
    }

  11. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3991 posts

    Posted 26 Jun Link to this post

    Hello, Cesar,  

    You can find below the converted code to VB.NET: 
        Private Sub radGridView1_CellEditorInitialized(ByVal sender As Object, ByVal e As GridViewCellEventArgs)
            Dim mccb As RadMultiColumnComboBoxElement = TryCast(e.ActiveEditor, RadMultiColumnComboBoxElement)
    
            If mccb IsNot Nothing Then
                mccb.EditorControl.ShowFilteringRow = True
                mccb.EditorControl.EnableFiltering = True
                RemoveHandler mccb.EditorControl.ViewCellFormatting, AddressOf EditorControl_ViewCellFormatting
                AddHandler mccb.EditorControl.ViewCellFormatting,AddressOf EditorControl_ViewCellFormatting
            End If
        End Sub
    
        Private Sub EditorControl_ViewCellFormatting(ByVal sender As Object, ByVal e As CellFormattingEventArgs)
            Dim filterCell As GridFilterCellElement = TryCast(e.CellElement, GridFilterCellElement)
    
            If filterCell IsNot Nothing Then
                filterCell.FilterButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            End If
        End Sub
    Feel free to use our free online Telerik Converter for converting C# to VB.NET and vice versa: https://converter.telerik.com/ 

    I hope this information helps.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  12. Cesar
    Cesar avatar
    16 posts
    Member since:
    May 2019

    Posted 27 Jun in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thank you. The code works perferct. But I tried to convert the PopupClosing Sub to VB.NET using the Telerik converter, but it is not converting well. This is the code it converts.

        Private Sub mccb_PopupClosing(ByVal sender As Object, ByVal args As RadPopupClosingEventArgs)
            Dim mccb As RadMultiColumnComboBoxElement = TryCast(sender, RadMultiColumnComboBoxElement)
            Dim shouldCancel As Boolean = mccb.EditorControl.CurrentRow = mccb.EditorControl.MasterView.TableFilteringRow
            args.Cancel = shouldCancel
        End Sub
    End Class

  13. Nadya
    Admin
    Nadya avatar
    389 posts

    Posted 29 Jun Link to this post

    Hello Cesar,

    I suppose that you would like to keep the popup open while the filtering row is active as shown in this post. Please refer to the PopupClosing event in VB:

    Private Sub mccb_PopupClosing(ByVal sender As Object, ByVal args As RadPopupClosingEventArgs)
        Dim mccb As RadMultiColumnComboBoxElement = TryCast(sender, RadMultiColumnComboBoxElement)
        Dim shouldCancel As Boolean = False
        If mccb.EditorControl.CurrentRow Is mccb.EditorControl.MasterView.TableFilteringRow Then
            shouldCancel = True
        End If
        args.Cancel = shouldCancel
    End Sub
    

    I hope this helps. Do not hesitate to contact me if you have other questions.

    Regards,
    Nadya
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  14. Cesar
    Cesar avatar
    16 posts
    Member since:
    May 2019

    Posted 21 Jul in reply to Nadya Link to this post

    Hi, thank you for the solution. I am using the code in a gridView Column and the filter runs Ok, but, when I select a row after write something in filter row, the Tab and Enter keys don't move the cursor to the next Cell or Next Row. Could you help me please?
  15. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3991 posts

    Posted 24 Jul Link to this post

    Hello, Cesar, 

    I would like to note that when you make the filtering row current, pressing the Tab key is expected to navigate to the next cell without closing the popup. Please refer to the attached gif file illustrating the behavior on my end. However, if you filter the popup grid and select a data row, it is desired behaviour to close the popup upon selection.

    However, it seems that the behavior on your side is different. I have attached my sample project. Could you please specify what changes I need to perform in order to obtain the undesired behavior that you are facing? Thank you in advance. 

    I am looking forward to your reply.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

  16. Cesar
    Cesar avatar
    16 posts
    Member since:
    May 2019

    Posted 24 Jul in reply to Dess | Tech Support Engineer, Sr. Link to this post

    My code is working as you show in the gif file. But, the issue I have is in the grid navigation when the focus returns to grid after I select some record in the dropdown.

    To reply the issue, please add more columns to your grid, and try to move to next cell with Tab Key or Enter Key, after select a record in dropdown using the row filter.

  17. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3991 posts

    Posted 27 Jul Link to this post

    Hello, Cesar, 

    Following the provided details, I have added more columns to RadGridView, activated the editor for the GridViewMultiComboBoxColumn, filtered some records and then, pressing Enter is expected to close the active editor in the filter cell in the popup grid:

    If the editor is active and you press Tab, the editor is moved to the next cell:

    Once filtered the popup grid and selecting a row, the main grid's editor is still active and pressing Tab/Enter is not executed at all. This is because it doesn't have the focus in this situation. I would like to note that this is not a standard case to have an editor inside another editor, e.g. main RadGridView's editor is active and you enable the filtering row for the popup grid from where you can active another editor. You can handle this case and return the focus back to the main grid's editor by using the following code snippet:

        Private Sub RadGridView_CellEditorInitialized(sender As Object, e As GridViewCellEventArgs)
            Dim mccb As RadMultiColumnComboBoxElement = TryCast(e.ActiveEditor, RadMultiColumnComboBoxElement)
    
            If mccb IsNot Nothing Then
                mccb.AutoSizeDropDownToBestFit = True
                mccb.EditorControl.ShowFilteringRow = True
                mccb.EditorControl.EnableFiltering = True
                mccb.EditorControl.FilterDescriptors.Clear()
                mccb.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown
                mccb.EditorControl.CurrentRow = mccb.EditorControl.MasterView.TableFilteringRow
                RemoveHandler mccb.EditorControl.ViewCellFormatting, AddressOf EditorControl_ViewCellFormatting
                AddHandler mccb.EditorControl.ViewCellFormatting, AddressOf EditorControl_ViewCellFormatting
    
                RemoveHandler mccb.PopupClosing, AddressOf mccb_PopupClosing
                AddHandler mccb.PopupClosing, AddressOf mccb_PopupClosing
    
                RemoveHandler mccb.PopupClosed, AddressOf mccb_PopupClosed
                AddHandler mccb.PopupClosed, AddressOf mccb_PopupClosed
            End If
        End Sub
    
        Private Sub mccb_PopupClosed(sender As Object, args As RadPopupClosedEventArgs)
            Dim mccb As RadMultiColumnComboBoxElement = TryCast(Me.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
            If mccb IsNot Nothing Then
                mccb.TextBoxElement.TextBoxItem.HostedControl.Focus()
            End If
        End Sub

    However, I would recommend you to consider using either the autocomplete functionality that GridViewMultiComboBoxColumn offers, or use the custom filtering functionality that the EditorControl allows you to control which rows will be visible or not.

    Should you have further questions please let me know.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

Back to Top