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

Advanced RadMultiColumnComboBox - filtering with grid filters enabled

1 Answer 126 Views
MultiColumn ComboBox
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 22 Oct 2013, 02:27 PM
Hello,

I have a solution (see example below) how to use RadMultiColumnComboBox auto filter and it's EditorControl's column filters enabled at the same time. Howewer, there is a problem and I'd be glad if you have any solution.

I've attached a picture of working and non working example of filtering.

Filtering as shown on page http://www.telerik.com/help/winforms/multicolumncombobox-filtering.html is not enaugh for what I am trying to do.
My goal is to have RadMultiColumnComboBox auto filtering and also it's EditorControl columns filtering enabled at the same time.
This example shows how to solve this. But it only works when manipulating with short strings in the RadMultiColumnCombobox's DataSource (which is DataTable). 
But as soon as longer string is placed inside DataTable, strange problem accures. 
Try two things:
1.) Run the program. Click on the RadMultiColumnComboBox. Popup with RadGridView accures automatically. Now click on the LastName filter. Enter character 0. Filtering works for now.
2.) Now erase this character and enter another one - z. There is no last name that contains letter z, true... but that should not crach the application. The application crashes. Why? If you shorten the first name in the first row and run the application again, this doesn't happen.

Below there is a Form1.vb with all the code needed. In designer I only have one RadMulticolumnComboBox1 control, placed on Form1.

Imports Telerik.WinControls.UI
Imports Telerik.WinControls.Data
 
Public Class Form1
    Private shouldNotCancelPopup = True
 
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim dt As New DataTable
        dt.Columns.Add("FirstName")
        dt.Columns.Add("LastName")
        dt.Rows.Add("Selectt one", "")
        dt.Rows.Add("Very very loooong looong first name", "Last Name 0") 'This one is the troublemaker. I do not know why.
 
        dt.Rows.Add("Short first name 1", "Last Name 1")
        dt.Rows.Add("Short first name 2", "Last Name 2")
 
        Me.RadMultiColumnComboBox1.DataSource = dt
        Me.RadMultiColumnComboBox1.EditorControl.Rows(0).IsPinned = True
        Me.RadMultiColumnComboBox1.DisplayMember = "FirstName"
        Me.RadMultiColumnComboBox1.ValueMember = "LastName"
        setChangeableVisibilityStyle(RadMultiColumnComboBox1)
        enableEditorControlFiltering(Me.RadMultiColumnComboBox1)
        linkComboBoxFilterWithHisEditorControlFilter(RadMultiColumnComboBox1)
    End Sub
 
    Public Sub enableEditorControlFiltering(ByRef cb As RadMultiColumnComboBox)
        cb.EditorControl.ShowRowHeaderColumn = False
        cb.EditorControl.EnableFiltering = True
        cb.EditorControl.ShowFilteringRow = True
        AddHandler cb.EditorControl.MouseLeave, AddressOf cb_EditorControl_MouseLeave
        AddHandler cb.DropDownClosing, AddressOf cb_DropDownClosing
        AddHandler cb.EditorControl.CellClick, AddressOf cb_GridWithoutCheckBoxes_CellClick
    End Sub
 
    Private Sub cb_DropDownClosing(ByVal sender As System.Object, ByVal args As Telerik.WinControls.UI.RadPopupClosingEventArgs)
        If shouldNotCancelPopup Then
            args.Cancel = True       
        End If
    End Sub
 
    Private Sub cb_EditorControl_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) 'Handles cb_EditorControl_MouseLeave.MouseLeave
        shouldNotCancelPopup = False
    End Sub
 
    Private Sub cb_GridWithoutCheckBoxes_CellClick(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs)
        Try
            If e.RowIndex >= 0 Then            'If valid row
                shouldNotCancelPopup = False
            Else
                shouldNotCancelPopup = True
            End If
        Catch ex As Exception
        End Try
    End Sub
 
    Public Sub setChangeableVisibilityStyle(ByRef cb As RadMultiColumnComboBox)
        cb.EditorControl.BestFitColumns()
        cb.MultiColumnComboBoxElement.AutoSizeDropDownToBestFit = True
    End Sub
 
    Public Sub linkComboBoxFilterWithHisEditorControlFilter(ByVal cb As RadMultiColumnComboBox)
        cb.AutoFilter = True
        Dim filter As New FilterDescriptor()
        filter.PropertyName = cb.DisplayMember
        filter.Operator = FilterOperator.Contains
        cb.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
    End Sub
End Class

1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 25 Oct 2013, 10:39 AM
Hello Boris,

Thank you for contacting us.

I was able to identify where the issue origins from. It appears that the AutoSizeDropDownToBestFit property of the MultiColumnComboBoxElement is causing this trouble. My suggestion is to set it to false. And since by default the filtering operations are controlled by the AutoFilter property this is the best workaround I can provide you with at the moment due to the implementation of RadGridView.

Let me know if there is anything else.

Regards,
George
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 >>
Tags
MultiColumn ComboBox
Asked by
Boris
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or