DashboardDesigner.RangeFilterDefaultValue Event
Provides the capability to specify the default selected range in the Range Filter dashboard item.
Namespace: DevExpress.DashboardWin
Assembly: DevExpress.Dashboard.v24.1.Win.dll
NuGet Package: DevExpress.Win.Dashboard
Declaration
Event Data
The RangeFilterDefaultValue event's data class is RangeFilterDefaultValueEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
ArgumentDateTimeGroupInterval | Gets the date-time group interval applied to the Range Filter argument. |
ArgumentType | Gets the type of Range Filter’s argument values. |
DashboardItemName | Gets the component name of the Range Filter for which the event was raised. |
Range | Gets or sets the selected range for the current Range Filter dashboard item. |
Remarks
Use the RangeFilterDefaultValueEventArgs.DashboardItemName event parameter to get the component name of the Range Filter item that raises the event. The RangeFilterDefaultValueEventArgs.Range property allows you to specify the selected range.
To apply default filtering to other master filter items, handle the DashboardDesigner.MasterFilterDefaultValues event.
Important
This event is not raised in asynchronous mode. Use the SetInitialDashboardState event to set the default selected range. See Manage Dashboard State for more information about a dashboard state.
Example
This example demonstrates how to initialize master filter in a dashboard loaded in the DashboardViewer control. The code for the DashboardDesigner control is the same, because the DashboardDesigner’s events have the same name and functionality.
The following code initializes master filter items:
- The DashboardViewer.MasterFilterDefaultValues event is handled to apply filtering to Grid and Tree View.
- The DashboardViewer.RangeFilterDefaultValue event is used to select the specified date range in the Range Filter.
Master filter initialization can apply one item’s master filter to another master filter item - a mutual filtering occurs. In that scenario, the MasterFilterDefaultValues event has limitations if the Neutral Filter mode is disabled.
using DevExpress.DashboardCommon;
using System;
using System.Linq;
namespace Dashboard_MFDefaultValues
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
public Form1() {
InitializeComponent();
dashboardViewer1.UseNeutralFilterMode = true;
dashboardViewer1.ConfigureDataConnection += DashboardViewer1_ConfigureDataConnection;
dashboardViewer1.MasterFilterDefaultValues += DashboardViewer1_MasterFilterDefaultValues;
dashboardViewer1.RangeFilterDefaultValue += DashboardViewer1_RangeFilterDefaultValue;
dashboardViewer1.Dashboard = new Dashboard1();
}
private void DashboardViewer1_ConfigureDataConnection(object sender, DashboardConfigureDataConnectionEventArgs e)
{
ExtractDataSourceConnectionParameters connParameters = e.ConnectionParameters as ExtractDataSourceConnectionParameters;
connParameters.FileName = "Data\\SalesPerson.dat";
}
private void DashboardViewer1_MasterFilterDefaultValues(object sender, MasterFilterDefaultValuesEventArgs e) {
if (e.ItemComponentName == "gridDashboardItem1") {
e.FilterValues = e.AvailableFilterValues.Where(v => (string)v["Sales Person"] == "Laura Callahan");
}
if (e.ItemComponentName == "treeViewDashboardItem1") {
e.FilterValues = e.AvailableFilterValues.Where(v => (string)v["Category"] == "Beverages" ||
(string)v["Product"] == "Aniseed Syrup");
}
}
private void DashboardViewer1_RangeFilterDefaultValue(object sender, RangeFilterDefaultValueEventArgs e) {
if (e.DashboardItemName == "rangeFilterDashboardItem1") {
e.Range = new RangeFilterSelection(new DateTime(2015, 06, 01), new DateTime(2016, 04, 01));
}
}
}
}