DataFilter control allows you to configure the Checklist filter to implement the filter summaries using AggregateType property 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 Model filter are listed.
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 as shown in the above example using AggregateType property.
C# |
コードのコピー
|
---|---|
private void C1DataFilter_FilterAutoGenerating(object sender, FilterAutoGeneratingEventArgs e) { foreach (Filter f in c1DataFilter.Filters) { if (f.PropertyName == "Brand") { var brandFilter = f as ChecklistFilter; brandFilter.FilterSummary.Label = "Models:"; brandFilter.FilterSummary.PropertyName = "Brand"; brandFilter.FilterSummary.AggregateType = AggregateType.Count; } if (f.PropertyName == "Model") { var modelFilter = f as ChecklistFilter; modelFilter.FilterSummary.AggregateType = AggregateType.Max; modelFilter.FilterSummary.CustomFormat = "C0"; modelFilter.FilterSummary.Label = "Max price: "; modelFilter.FilterSummary.PropertyName = "Price"; } if (f.PropertyName == "Price") { var modelFilter = f as RangeFilter; modelFilter.Maximum = _data.Max(x => (x as Car).Price); modelFilter.Minimum = _data.Min(x => (x as Car).Price); modelFilter.Increment = 1000; modelFilter.Format = "F0"; } if (f.PropertyName == "TransmissAutomatic") { var taFilter = f as ChecklistFilter; taFilter.HeaderText = "Transmiss Automatic"; taFilter.ItemsSource = new List<TransmissAutomatic>() { new TransmissAutomatic() { DisplayValue = "Yes", Value = "Yes" }, new TransmissAutomatic() { DisplayValue = "No", Value = "No" }, new TransmissAutomatic() { DisplayValue = "Empty", Value = null } }; taFilter.DisplayMemberPath = "DisplayValue"; taFilter.ValueMemberPath = "Value"; taFilter.ShowSelectAll = false; } if (f.PropertyName == "DateProductionLine") { var modelFilter = f as DateRangeFilter; modelFilter.UpperValue = _data.Max(x => (x as Car).DateProductionLine); modelFilter.LowerValue = _data.Min(x => (x as Car).DateProductionLine); modelFilter.Maximum = modelFilter.UpperValue.Value; modelFilter.Minimum = modelFilter.LowerValue.Value; } } } |