在使用RIA服务的Silverlight中,使用“FilterDescriptor”实例implement simple data filtering非常容易。
但是我有一个案例,我有几个过滤器,我想根据其他过滤器启用或禁用它们。
看起来简单的“启用”属性会让这很容易 - 但没有。
有没有办法实现这一目标,而不是每次选中相关复选框时手动定义我需要的所有过滤器。也许是一个子类? (我还没来得及尝试这个)
答案 0 :(得分:2)
我这样做是通过默认将每个设置为-1,并在FilterDescriptor中使用IgnoredValue =“ - 1”。根据您使用的语言,您也可以使用null或Nothing。 肯
答案 1 :(得分:1)
使用“RIA Services DataFilter Control for Silverlight”,排序/过滤/分组真的很容易。 http://riadatafilter.codeplex.com/
答案 2 :(得分:1)
使用转换器返回特定值(例如)0表示空值或Nothing。然后使用0作为IgnoredValue
答案 3 :(得分:0)
好的,这就是我的工作。我重置过滤器,然后设置它们,你可以循环它们并将它们设置为你喜欢的任何东西......
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