DataFilter for WPF
集計のフィルタリング
DataFilter の操作 > 集計のフィルタリング

DataFilter control allows you to configure the Checklist filter to implement the filter summaries using AggregateType property of the FilterSummary class and by assigning AggregateType Enum. The feature makes it easier for you to analyze the count, sum, maximum and minimum values of the filter items.

Let us take a use case to display count and maximum values of the filter items in a checklist filter. In the image and example below, count of the individual filter items of the Brand filter are listed and maximum price values for the filter items in the Category filter are listed.

filtering

You can use the following code to display the count of the filter items and the maximum value of a filter item corresponding to the data.

Private Sub C1DataFilter_FilterAutoGenerating(sender As Object, e As C1.DataFilter.FilterAutoGeneratingEventArgs)
    Select Case e.[Property].Name
        Case "Name"
            Dim brandFilter = CType(e.Filter, C1.WPF.DataFilter.ChecklistFilter)
            brandFilter.ItemsSource = _products
            brandFilter.ValueMemberPath = "Name"
            'Brand フィールドに定義されたチェックリストフィルタの集計を定義します
            'この集計には、各Brandで利用可能な車の数が表示されます
            brandFilter.FilterSummary.AggregateType = AggregateType.Count
            brandFilter.FilterSummary.Label = "Count"
            brandFilter.FilterSummary.PropertyName = "Name"
            'すべてのフィルタ項目を選択します
            brandFilter.SelectAll()
        Case "Color"
            Dim categoryFilter = CType(e.Filter, C1.WPF.DataFilter.ChecklistFilter)
            categoryFilter.ItemsSource = _products
            categoryFilter.ValueMemberPath = "Color"
            'Category フィールドに定義されたチェックリストフィルタの集計を定義します
            'この集計には、特定のカテゴリの車の最大価格が表示されます
            categoryFilter.FilterSummary.AggregateType = AggregateType.Max
            categoryFilter.FilterSummary.Label = "Max"
            categoryFilter.FilterSummary.PropertyName = "Price"

            'すべてのフィルタ項目を選択します
            categoryFilter.SelectAll()
        Case "Price"
            Dim priceFilter = CType(e.Filter, C1.WPF.DataFilter.RangeFilter)
            priceFilter.Maximum = _products.AsEnumerable().Max(Function(x) x.Price)
            priceFilter.Minimum = _products.AsEnumerable().Min(Function(x) x.Price)
            priceFilter.Increment = 1000
            priceFilter.Digits = 0
        Case Else
            e.Cancel = True
    End Select
End Sub
private void C1DataFilter_FilterAutoGenerating(object sender, C1.DataFilter.FilterAutoGeneratingEventArgs e)
{
    switch (e.Property.Name)
    {
        //Brand フィルタのチェックリスト項目を設定します
        case "Name":
            var brandFilter = (C1.WPF.DataFilter.ChecklistFilter)e.Filter;
            brandFilter.ItemsSource = _products;
            brandFilter.ValueMemberPath = "Name";
            //Brand フィールドに定義されたチェックリストフィルタの集計を定義します
            //この集計には、各Brandで利用可能な車の数が表示されます
            brandFilter.FilterSummary.Label = "Count";
            brandFilter.FilterSummary.PropertyName = "Name";
            brandFilter.FilterSummary.AggregateType = AggregateType.Count;

            //すべてのフィルタ項目を選択します
            brandFilter.SelectAll();
            break;
        //Category フィルタのチェックリスト項目を設定します
        case "Color":
            var categoryFilter = (C1.WPF.DataFilter.ChecklistFilter)e.Filter;
            categoryFilter.ItemsSource = _products;
            categoryFilter.ValueMemberPath = "Color";
            //Category フィールドに定義されたチェックリストフィルタの集計を定義します
            //この集計には、特定のカテゴリの車の最大価格が表示されます
            categoryFilter.FilterSummary.Label = "Max";
            categoryFilter.FilterSummary.PropertyName = "Price";
            categoryFilter.FilterSummary.AggregateType = AggregateType.Max;

            //すべてのフィルタ項目を選択します
            categoryFilter.SelectAll();
            break;
        //Price フィルタの最小値/最大値を設定します
        case "Price":
            var priceFilter = (C1.WPF.DataFilter.RangeFilter)e.Filter;
            priceFilter.Maximum = _products.AsEnumerable().Max(x => x.Price);
            priceFilter.Minimum = _products.AsEnumerable().Min(x => x.Price);
            priceFilter.Increment = 1000;
            priceFilter.Digits = 0;
            break;
        //他のすべてのフィルタの作成をキャンセルします
        default:
            e.Cancel = true;
            break;
    }
}