views:

217

answers:

3

In Silverlight with RIA services it is very easy to implement simple data filtering with 'FilterDescriptor' instances.

However I've got a case where I have several filters and I want to enable or disable them based on other filters.

It seems like a simple 'Enabled' property would make this really easy - but there is none.

Is there a way to achieve this without just manually defining all the filters I need every time the relevant checkbox is checked. Perhaps a subclass? (I haven't had time to try this myself yet)

+1  A: 

Sorting / Filtering / Grouping is really will be easy with using "RIA Services DataFilter Control for Silverlight". http://riadatafilter.codeplex.com/

Alexander Bykin
this is a cool control - however my situation is not complex enough to have the user create their own filters. i need to define my flters myself
Simon_Weaver
+1  A: 

I am doing this by setting each one to -1 by default, and have the IgnoredValue="-1" in the FilterDescriptor. You can also use null or Nothing depending on your language your using. Ken

Ken
ahh. the key thing I did not know about here is IgnoredValue : http://msdn.microsoft.com/en-us/library/system.windows.controls.filterdescriptor.ignoredvalue(VS.91).aspx
Simon_Weaver
A: 

Ok, here is what I do. I reset the filter, then set them, you can loop thru them and set them to anything you like...

Private Sub AppPickerComboBox_SelectionChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles AppPickerComboBox.SelectionChanged
    For fd As Integer = AppTranDomainDataSource.FilterDescriptors.Count - 1 To 0 Step -1
        If AppTranDomainDataSource.FilterDescriptors(fd).PropertyPath = "Application_ID" Then
            AppTranDomainDataSource.FilterDescriptors.Remove(AppTranDomainDataSource.FilterDescriptors(fd))
        End If
    Next fd
    AppTranDomainDataSource.FilterDescriptors.Add(New FilterDescriptor With {.PropertyPath = "Application_ID", .Operator = FilterOperator.IsEqualTo, .Value = AppPickerComboBox.SelectedValue, .IgnoredValue = -1})
End Sub
Ken