CompositeFilterDescriptor not working as expected

5 posts, 0 answers
  1. Jason Parrish
    Jason Parrish avatar
    87 posts
    Member since:
    Sep 2009

    Posted 28 Mar 2012 Link to this post

    I am developing a filter panel usercontrol that will allow my user to create complex filters.  My control follows the same structure as the documentation, but it does not work as expected.  It appears the last filterdescriptor added to the "main" composite filter is the only filter applied.

    http://www.telerik.com/help/winforms/gridview-filtering-setting-filters-programmatically-composite-descriptors.html 

    So, I took the exact code from the documentation, and it appears it is behaving incorrectly as well.  See below.  Also, notice my screenshot?  I would expect the Expression property to have the combination of the two filterdescriptors similar to the wording in documentation. Thoughts?

      Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
     
     
            Dim oFooData As New BindingList(Of SampleData)
     
            Dim i As Integer = 1
            While i < 50
                oFooData.Add(New SampleData(10 * i, 3 * i, "Game"))
                i += 1
            End While
     
            i = 0
            While i < 50
                oFooData.Add(New SampleData(5 * i, 0, "Aatar"))
                i += 1
            End While
     
            RadGridView1.DataSource = oFooData
     
            Dim compositeFilter1 As New CompositeFilterDescriptor()
            compositeFilter1.FilterDescriptors.Add(New FilterDescriptor("UnitsInStock", FilterOperator.IsGreaterThan, 100))
            compositeFilter1.FilterDescriptors.Add(New FilterDescriptor("ProductName", FilterOperator.StartsWith, "G"))
            compositeFilter1.LogicalOperator = FilterLogicalOperator.[Or]
            Dim filter2 As New FilterDescriptor("UnitsOnOrder", FilterOperator.IsEqualTo, 0)
            Dim filterDescriptor2 As New CompositeFilterDescriptor()
            filterDescriptor2.FilterDescriptors.Add(compositeFilter1)
            filterDescriptor2.FilterDescriptors.Add(filter2)
            filterDescriptor2.LogicalOperator = FilterLogicalOperator.[And]
     
            Me.RadGridView1.FilterDescriptors.Add(filterDescriptor2)
     
        End Sub
     
     
     
     
     
     
    Public Class SampleData
        Property UnitsInStock As Integer
        Property UnitsOnOrder As Integer
        Property ProductName As String
     
        Public Sub New(ByVal UnitsInStock As Integer, UnitsOnOrder As Integer, ProductName As String)
            _UnitsInStock = UnitsInStock
            _UnitsOnOrder = UnitsOnOrder
            _ProductName = ProductName
        End Sub
     
    End Class
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 02 Apr 2012 Link to this post

    Hello Jason,

    Thank you for writing.

    Indeed, I can confirm that the observed issue appears. I am logging it in PITS and we will address it accordingly. Feel free to add your vote for it here: http://www.telerik.com/support/pits.aspx#/public/winforms/10550

    Your Telerik points have been updated for this report.

    Meanwhile, what I can suggest is to use the CustomFiltering functionality of RadGridView. Here is how you can apply the same filter with it:
    Me.RadGridView1.MasterTemplate.FilterPredicate = New Predicate(Of GridViewRowInfo)(AddressOf PerformFiltering)
    '''''''
     Private Function PerformFiltering(ByVal row As GridViewRowInfo) As Boolean
            If row.Cells("UnitsOnOrder").Value = 0 Then
                If row.Cells("UnitsInStock").Value > 100 Or row.Cells("ProductName").Value.ToString.StartsWith("G") Then
                    Return True
                End If
            Else
                Return False
            End If
        End Function

    More information regarding this functionality can be found here: http://www.telerik.com/help/winforms/gridview-filtering-custom-filtering.html.

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.
     
    Kind regards,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jason Parrish
    Jason Parrish avatar
    87 posts
    Member since:
    Sep 2009

    Posted 02 Apr 2012 Link to this post

    Thank you.  The problems with the alternate solution, that is custom filtering, are 1) the user still needs to perform the standard grid filtering, and 2) the complex filtering needs to be dynamic of course.

    Will this bug possibly be corrected in an internal build soon?  
  5. Jason Parrish
    Jason Parrish avatar
    87 posts
    Member since:
    Sep 2009

    Posted 02 Apr 2012 Link to this post

    I found a better workaround.  From my collection of possible composite filters, I am building a filter expression.  And then, I apply the filter expression directly to grid's dataview.

    _GridView.MasterTemplate.DataView.FilterExpression = sbMainFilterExpression.ToString
  6. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 05 Apr 2012 Link to this post

    Hello Jason,

    I am glad to hear that you have found a suitable workaround for your case.

    I cannot engage with an exact time frame when this issue will be resolved, however, we will do our best to fit it in our plans for Q2 2012, which is expected in June.

    I hope that this works for you.
     
    Kind regards,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready