This is a migrated thread and some comments may be shown as answers.
BAT FILTERING
6 Answers 14 Views
This is a migrated thread and some comments may be shown as answers.
Javier
Top achievements
Rank 1
Javier asked on 11 Jul 2016, 06:19 PM

Regrads.

 

In my proyect i'm using a MultiColumnComboBox control with data Source, but the table have very much information.  In the moment when user is writing the  MultiColumnComboBox begin filtering, but  this teke several time to search the data. i use the next code to filter: (vb.net)

 

 Sub conf_combo_pacientes()
        Me.tb_identificacion.AutoFilter = True
        Me.tb_identificacion.DisplayMember = "Identificación"

        Dim filter As New FilterDescriptor()
        filter.PropertyName = Me.tb_identificacion.DisplayMember
        filter.[Operator] = FilterOperator.Contains
        Me.tb_identificacion.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
        tb_identificacion.MultiColumnComboBoxElement.EditorControl.EnableCustomFiltering = True
        AddHandler tb_identificacion.MultiColumnComboBoxElement.EditorControl.CustomFiltering, AddressOf EditorControl_CustomFilteringrl
        AddHandler tb_identificacion.KeyDown, AddressOf TB_CEDULA_RL_KeyDown

        tb_identificacion.DropDownSizingMode = SizingMode.UpDownAndRightBottom
        tb_identificacion.AutoSizeDropDownToBestFit = True

    End Sub

 

Private Sub EditorControl_CustomFilteringrl(sender As Object, e As Telerik.WinControls.UI.GridViewCustomFilteringEventArgs)
        Dim element As RadMultiColumnComboBoxElement = tb_identificacion.MultiColumnComboBoxElement

        Dim textToSearch As String = tb_identificacion.Text
        If AutoCompleteMode.Append = (element.AutoCompleteMode And AutoCompleteMode.Append) Then
            If element.SelectionLength > 0 AndAlso element.SelectionStart > 0 Then
                textToSearch = tb_identificacion.Text.Substring(0, element.SelectionStart)
            End If
        End If
        If String.IsNullOrEmpty(textToSearch) Then
            e.Visible = True
            For i As Integer = 0 To element.EditorControl.ColumnCount - 1
                e.Row.Cells(i).Style.Reset()
            Next
            e.Row.InvalidateRow()
            Return
        End If
        e.Visible = False
        For i As Integer = 0 To element.EditorControl.ColumnCount - 1
            Dim text As String = e.Row.Cells(i).Value.ToString()
            If text.IndexOf(textToSearch, 0, StringComparison.InvariantCultureIgnoreCase) >= 0 Then
                e.Visible = True
                e.Row.Cells(i).Style.CustomizeFill = True
                e.Row.Cells(i).Style.DrawFill = True
                e.Row.Cells(i).Style.BackColor = Color.FromArgb(201, 252, 254)
            Else
                e.Row.Cells(i).Style.Reset()
            End If
        Next
        e.Row.InvalidateRow()
    End Sub

    Private Sub tb_identificacion_KeyDown(sender As Object, e As KeyEventArgs) Handles tb_identificacion.KeyDown
        Try
            If e.KeyCode = System.Windows.Forms.Keys.Enter Then
                If Me.tb_identificacion.ValueMember <> "" Then
                    tb_identificacion.SelectedValue = tb_identificacion.EditorControl.CurrentRow.Cells(tb_identificacion.ValueMember).Value
                Else
                    tb_identificacion.SelectedValue = tb_identificacion.EditorControl.CurrentRow.Cells(tb_identificacion.DisplayMember).Value
                End If

                tb_identificacion.Text = tb_identificacion.EditorControl.CurrentRow.Cells(tb_identificacion.DisplayMember).Value.ToString()
                tb_identificacion.MultiColumnComboBoxElement.ClosePopup()
                tb_identificacion.MultiColumnComboBoxElement.TextBoxElement.TextBoxItem.SelectAll()
            End If
        Catch ex As Exception

        End Try
    End Sub

While the user is writing, then control is filtering but I do not want it so, i woluld like that the user to write but when user press key intro, in this moment the multiColumnComboBox  is filtering. But i don't know do it.

 

 

6 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 12 Jul 2016, 10:49 AM
Hi Javier,

Thank you for writing.

The Enter key is used for selecting an item and it closes the drop down. To improve the performance in this case you can enable the filtering after a particular number of characters are entered. For example:
Private Sub RadGridView1_CellEditorInitialized(ByVal sender As Object, ByVal e As GridViewCellEventArgs)
    Dim editor = TryCast(e.ActiveEditor, RadMultiColumnComboBoxElement)
    If editor IsNot Nothing Then
        editor.AutoFilter = True
        editor.EditorControl.FilterDescriptors.Add("Name", Telerik.WinControls.Data.FilterOperator.Contains, "")
      
        AddHandler editor.TextChanged, AddressOf Editor_TextChanged
    End If
End Sub
 
Private Sub Editor_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
    Dim editor = DirectCast(sender, RadMultiColumnComboBoxElement)
    If editor.Text.Length >= 5 AndAlso editor.EditorControl.FilterDescriptors.Count = 0 Then
        editor.AutoFilter = True
        Dim filter As New FilterDescriptor()
        filter.PropertyName = editor.DisplayMember
        filter.Operator = FilterOperator.Contains
        editor.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
 
    Else
        editor.AutoFilter = False
        editor.EditorControl.MasterTemplate.FilterDescriptors.Clear()
    End If
End Sub

Is this approach suitable for your scenario?

I am looking forward to your reply.

Regards,
Dimitar
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.
0
Javier
Top achievements
Rank 1
answered on 12 Jul 2016, 04:05 PM

Regards, thanks for you reply.

 

In this moment my MultiColumnComboBox have 3 columns (id, name, gender),

 

i paste your code,  but in the line:  editor.EditorControl.FilterDescriptors.Add("Paciente",Telerik.WinControls.Data.FilterOperator.Contains, "")

I changed for the my column name. "Name" to "Paciente"

 

But it does not work, the control not filter. I deleted my code before

 

 

I deleted my code before
I deleted my code before
I deleted my code before
0
Javier
Top achievements
Rank 1
answered on 12 Jul 2016, 04:11 PM
Control no filter
0
Dimitar
Telerik team
answered on 13 Jul 2016, 08:31 AM
Hi Javier,

You need to use one of the column names (not the header text) for this value. In your code this is set to the display member:
filter.PropertyName = Me.tb_identificacion.DisplayMember

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
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.
0
Javier
Top achievements
Rank 1
answered on 13 Jul 2016, 03:51 PM

Regrads

 

i pasted this code:

 

  Private Sub RadGridView1_CellEditorInitialized(ByVal sender As Object, ByVal e As GridViewCellEventArgs)
        Dim editor = TryCast(e.ActiveEditor, RadMultiColumnComboBoxElement)
        If editor IsNot Nothing Then
            editor.AutoFilter = True
            editor.EditorControl.FilterDescriptors.Add((1), Telerik.WinControls.Data.FilterOperator.Contains, "")
            AddHandler editor.TextChanged, AddressOf Editor_TextChanged
        End If
    End Sub

    Private Sub Editor_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
        Dim editor = DirectCast(sender, RadMultiColumnComboBoxElement)
        If editor.Text.Length >= 5 AndAlso editor.EditorControl.FilterDescriptors.Count = 0 Then
            editor.AutoFilter = True
            Dim filter As New FilterDescriptor()
            filter.PropertyName = editor.DisplayMember
            filter.Operator = FilterOperator.Contains
            editor.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
            filter.PropertyName = Me.tb_identificacion.DisplayMember
        Else
            editor.AutoFilter = False
            editor.EditorControl.MasterTemplate.FilterDescriptors.Clear()
        End If
    End Sub

 

but not filter nothing .

0
Dimitar
Telerik team
answered on 14 Jul 2016, 07:31 AM
Hi Javier,

Thank you for writing.

I have attached a sample project that shows how this works on my side. Please note that you need to enter at least 5 letters in order to start filtering.

I hope this will be useful. 

Regards,
Dimitar
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.
Asked by
Javier
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Javier
Top achievements
Rank 1
Share this question
or