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

Excel-like filtering doesn't preload the CompositeFilterForm appropriately

3 Answers 28 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Garrett
Top achievements
Rank 1
Garrett asked on 07 Mar 2018, 08:05 PM
We use a RadGridView on our WinForms application. We are trying to add filtering, but nothing behaves the way we want it to.

When I go to the filter -> Available Filters -> Equals, I would expect it to load the form with the appropriate options prefilled (i.e., equal to today). However, the form lacks values and does not adapt for which filter I select.

Here's my code so far:

Private Sub radGridView1_CreateCompositeFilterDialog(e As GridViewCreateCompositeFilterDialogEventArgs, senderName As String, column As GridViewDataColumn)
    Dim filterDialog As CompositeFilterForm
    Dim compositeFilterDescriptor As CompositeFilterDescriptor
 
    If senderName.ToLower() = "equals" Then
        compositeFilterDescriptor = New CompositeFilterDescriptor()
        compositeFilterDescriptor.LogicalOperator = FilterLogicalOperator.Or
        compositeFilterDescriptor.IsFilterEditor = True
        compositeFilterDescriptor.FilterDescriptors.Add(New DateFilterDescriptor("colReceived", FilterOperator.IsEqualTo, Date.Now) With {
                                                        .IsFilterEditor = True,
                                                        .IgnoreTimePart = True
        })
        compositeFilterDescriptor.FilterDescriptors.Add(New DateFilterDescriptor("colReceived", FilterOperator.IsEqualTo, Date.Now) With {
                                                        .IsFilterEditor = True,
                                                        .IgnoreTimePart = True
        })
    ElseIf senderName.ToLower() = "not equal to" Then
        compositeFilterDescriptor = New CompositeFilterDescriptor()
        compositeFilterDescriptor.LogicalOperator = FilterLogicalOperator.And
        compositeFilterDescriptor.NotOperator = True
        compositeFilterDescriptor.IsFilterEditor = True
        compositeFilterDescriptor.FilterDescriptors.Add(New FilterDescriptor("colReceived", FilterOperator.IsEqualTo, Date.Now))
        compositeFilterDescriptor.FilterDescriptors.Add(New FilterDescriptor("colReceived", FilterOperator.None, Nothing))
    ElseIf
        ....
    End If
 
    If compositeFilterDescriptor IsNot Nothing Then
        filterDialog = New CompositeFilterForm(column, compositeFilterDescriptor)
    Else
        filterDialog = New CompositeFilterForm()
    End If
    AddHandler filterDialog.FormClosing, AddressOf test2
    e.Dialog = filterDialog
End Sub

This is subscribed to in the MouseUp event of any of the Available Filter menu items (which has some custom values passed in through a lambda):

Private Sub item_MouseUp(sender As Object, column As GridViewDataColumn)
        AddHandler radGridView1.CreateCompositeFilterDialog, Sub(s As Object, e2 As GridViewCreateCompositeFilterDialogEventArgs)
        radGridView1_CreateCompositeFilterDialog(e2, CType(sender, RadItem).AccessibleName, column)
                                           End Sub
 
    End Sub

How can I load the window with the appropriate filters prefilled to the form?

 

It looks like we're on Telerik version 2017.3.1017.

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 08 Mar 2018, 09:22 AM
Hello, Garrett,

Thank you for writing.  

I would like to note that the available filter options in each column depend on the column type, e.g. for numeric columns you have one set of filter options, for the text columns you have another set and so on. By design, the CompositeFilterDialog will load the available filters that are already applied to the grid's column. In order to load any filters in the CompositeFilterDialog it is necessary to add a FilterDescriptor/CompositeFilterDescriptor and add the filtered column to the MasterTemplate.ExcelFilteredColumns. Here is demonstrated a sample code snippet which result is illustrated in the below screenshot.
Me.RadGridView1.EnableFiltering = True
Me.RadGridView1.ShowHeaderCellButtons = True
 
Dim filterDescriptor As New FilterDescriptor()
filterDescriptor.PropertyName = "ProductName"
filterDescriptor.Value = "Tofu"
filterDescriptor.Operator = FilterOperator.IsEqualTo
 
Dim cfd As New CompositeFilterDescriptor()
cfd.LogicalOperator = FilterLogicalOperator.And
cfd.FilterDescriptors.Add(filterDescriptor)
cfd.IsFilterEditor = True
 
Me.RadGridView1.FilterDescriptors.Add(cfd)
Me.RadGridView1.MasterTemplate.ExcelFilteredColumns.Add(Me.RadGridView1.Columns("ProductName"))



I hope this information helps. Should you have further questions I would be glad to help. 
 
 Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Garrett
Top achievements
Rank 1
answered on 08 Mar 2018, 02:37 PM

Dess,

Thank you for your reply. Unfortunately, this didn't solve my issue.

We already have Excel-like filtering enabled. I am trying to get the window that pops up to be loaded with the appropriate values. Please see my attached screenshot for what I'm talking about. I opened this window by clicking the "Equals" option under Available Filters. I expect that the values could be preloaded for the user.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 09 Mar 2018, 12:03 PM
Hello, Garrett,   

Thank you for writing back. 

According to the provided screenshot it seems that you use an older version of the suite because the CompositeFilterDialog now looks as it is illustrated in my previous post. I would recommend you to upgrade in order to benefit from the new dialog and introduced functionality.  I have also attached my sample project which successfully loads the already added FilterDescriptor.

I hope this information helps. If you have any additional questions, please let me know. 

  Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Garrett
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Garrett
Top achievements
Rank 1
Share this question
or