Back to Devexpress

DashboardDesigner.RangeFilterPredefinedDateTimePeriods Event

dashboard-devexpress-dot-dashboardwin-dot-dashboarddesigner-5c848b07.md

latest4.7 KB
Original Source

DashboardDesigner.RangeFilterPredefinedDateTimePeriods Event

Allows you to customize the list of predefined periods in the Edit Periods dialog for the Range Filter dashboard item.

Namespace : DevExpress.DashboardWin

Assembly : DevExpress.Dashboard.v25.2.Win.dll

NuGet Package : DevExpress.Win.Dashboard

Declaration

csharp
public event RangeFilterPredefinedDateTimePeriodsEventHandler RangeFilterPredefinedDateTimePeriods
vb
Public Event RangeFilterPredefinedDateTimePeriods As RangeFilterPredefinedDateTimePeriodsEventHandler

Event Data

The RangeFilterPredefinedDateTimePeriods event's data class is RangeFilterPredefinedDateTimePeriodsEventArgs. The following properties provide information specific to this event:

PropertyDescription
FilterTypeGets the filter type specified in the Edit Periods dialog.
ItemComponentNameGets the component name of the dashboard item for which the event was raised.
PeriodsProvides access to a collection of predefined periods displayed in the Edit Periods dialog.

Example

This example shows how to use the DashboardDesigner.RangeFilterPredefinedDateTimePeriods event to customize a default list of predefined periods from the Edit Periods dialog. Note that this list is customized when filtering by year is applied in the dialog.

csharp
using DevExpress.DashboardCommon;        
      //...           
    private void dashboardDesigner_RangeFilterPredefinedDateTimePeriods(object sender, RangeFilterPredefinedDateTimePeriodsEventArgs e) {
            if (e.ItemComponentName == "range" && e.FilterType == DateTimePeriodFilterType.Year) {
                // Creates a new 'Last 4 Years' period.
                FlowDateTimePeriodLimit startDate = new FlowDateTimePeriodLimit(DateTimeInterval.Year, -4);
                FlowDateTimePeriodLimit endDate = new FlowDateTimePeriodLimit(DateTimeInterval.Year, 0);
                DateTimePeriod period = new DateTimePeriod("Last 4 Years", startDate, endDate);
                e.Periods.Insert(3, period);

                // Removes the default 'Last Year' period.
                period = e.Periods.FirstOrDefault(p => p.Name == DashboardWinLocalizer.GetString(DashboardWinStringId.PeriodLastYear));
                e.Periods.Remove(period);
            }
        }
vb
Imports DevExpress.DashboardCommon
      '...           
    Private Sub dashboardDesigner_RangeFilterPredefinedDateTimePeriods(ByVal sender As Object, ByVal e As RangeFilterPredefinedDateTimePeriodsEventArgs)
            If e.ItemComponentName = "range" AndAlso e.FilterType = DateTimePeriodFilterType.Year Then
                ' Creates a new 'Last 4 Years' period.
                Dim startDate As New FlowDateTimePeriodLimit(DateTimeInterval.Year, -4)
                Dim endDate As New FlowDateTimePeriodLimit(DateTimeInterval.Year, 0)
                Dim period As New DateTimePeriod("Last 4 Years", startDate, endDate)
                e.Periods.Insert(3, period)

                ' Removes the default 'Last Year' period.
                period = e.Periods.FirstOrDefault(Function(p) p.Name = DashboardWinLocalizer.GetString(DashboardWinStringId.PeriodLastYear))
                e.Periods.Remove(period)
            End If
    End Sub

See Also

RangeFilterIncludeCurrentDate

DashboardDesigner Class

DashboardDesigner Members

DevExpress.DashboardWin Namespace