DashboardViewer.SingleFilterDefaultValue Event

Obsolete. Allows you to specify a default filter value for the Single Master Filter.

Namespace: DevExpress.DashboardWin

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

Declaration

[Obsolete("The SingleFilterDefaultValue event is now obsolete. Use MasterFilterDefaultValues instead.")]
[Browsable(false)]
public event SingleFilterDefaultValueEventHandler SingleFilterDefaultValue
<Obsolete("The SingleFilterDefaultValue event is now obsolete. Use MasterFilterDefaultValues instead.")>
<Browsable(False)>
Public Event SingleFilterDefaultValue As SingleFilterDefaultValueEventHandler

Event Data

The SingleFilterDefaultValue event handler receives an argument of the SingleFilterDefaultValueEventArgs type. The following properties provide information specific to this event.

Property Description
DashboardItemName Gets the name of the dashboard item for which the SingleFilterDefaultValue event was raised.
FilterValue Gets the default filter value.

Remarks

The SingleFilterDefaultValue event allows you to specify a default filter value for the Single Master Filter. It is raised for each master filter item with the enabled Single Master Filter mode.

The SingleFilterDefaultValueEventArgs.DashboardItemName property allows you to obtain the dashboard item name for which the event was raised. Use the SingleFilterDefaultValueEventArgs.FilterValue property to specify the required default filter value.

Examples

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:

Master filter initialization may 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. Refer to the How to apply default filtering to master filter items that affect each other example for more information.

Note

The complete sample project How to initialize master filters in Dashboard Viewer is available in the DevExpress Examples repository.

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));
            }
        }
    }
}
See Also