FilterProvider Delegate

FilterProvider Delegate

Old forum URL: forums.lhotka.net/forums/t/4940.aspx


lwmorris posted on Thursday, June 05, 2008

I'm using 3.0.4 of csla.net and wanted to do some filtering based on several properties of a class. I thought I could use the FilterProvider Delegate to query the properties of an object and return a true/false, however, the item passed into the delegate isn't the actual object, but rather the value of the property of the object being filtered.

I guess I was hoping that item was the object so I could then query it's properties. Is there any other methodolgy for filtering on multiple properties other than creating filtered lists based on filtered lists?

Thanks for your help

JoeFallon1 replied on Thursday, June 05, 2008

If you call Apply filter on a FilteredBindingList and use "" as the first parameter, then the BO gets passed to the filter and then you can check any of its properties.

ApplyFilter("", filterValue)

Private Shared Function MyFilter(ByVal item As Object, ByVal filterValue As Object) As Boolean
  Dim result As Boolean = False
  If item IsNot Nothing AndAlso filterValue IsNot Nothing Then
    Dim info As SomeROC.SomeInfo = DirectCast(item, SomeROC.SomeInfo )
    result = (info.Key =
CInt(filterValue) AndAlso  info.Code="someString")
  End If
  Return result
End Function

Joe

lwmorris replied on Thursday, June 05, 2008

Thank you very much Joe! That's just what I wanted!

Copyright (c) Marimer LLC