Back to Devexpress

RangeFilterSelection Class

dashboard-devexpress-dot-dashboardcommon-79071c60.md

latest12.3 KB
Original Source

RangeFilterSelection Class

A range in the Range Filter or Date Filter dashboard items.

Namespace : DevExpress.DashboardCommon

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

NuGet Package : DevExpress.Dashboard.Core

Declaration

csharp
public class RangeFilterSelection
vb
Public Class RangeFilterSelection

The following members return RangeFilterSelection objects:

Show 11 links

Remarks

Use the RangeFilterSelection.Minimum and RangeFilterSelection.Maximum properties to specify the range.

Example

The following example demonstrates how to set master filter in the Dashboard Viewer control.

The Dashboard Viewer control loads a dashboard with two master filter items - the Grid and Range Filter dashboard items. The Chart item displays the filtered data.

The DashboardViewer.ConfigureDataConnection event is handled to specify the Extract Data Source filename. The DashboardViewer.CustomizeDashboardTitle event handler creates the command button that executes the application’s SetMasterFilterMethod procedure.

The SetMasterFilterMethod procedure uses the DashboardViewer.SetMasterFilter method to select the rows in the Grid dashboard item. The DashboardViewer.SetRange method selects the range in the Range Filter dashboard item.

This example also demonstrates how to handle the DashboardViewer.MasterFilterSet and DashboardViewer.MasterFilterCleared events.

View Example: How to Set Master Filter in DashboardViewer

csharp
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Collections;
using DevExpress.DashboardCommon;
using System.IO;
using DevExpress.DashboardWin;
using System.Linq;
using DevExpress.XtraEditors;

namespace Dashboard_SetMasterFilter {
    public partial class Form1 : XtraForm {
        public Form1() {
            InitializeComponent();
            dashboardViewer1.ConfigureDataConnection += DashboardViewer1_ConfigureDataConnection;
            dashboardViewer1.CustomizeDashboardTitle += DashboardViewer1_CustomizeDashboardTitle;

            dashboardViewer1.LoadDashboard("Dashboard.xml");

            dashboardViewer1.MasterFilterSet += DashboardViewer1_MasterFilterSet;
            dashboardViewer1.MasterFilterCleared += DashboardViewer1_MasterFilterCleared;
        }

        private void SetMasterFilterMethod()
        {
            // Create a list with values to select in the Grid dashboard item.
            List<object> rowValues1 = new List<object>();
            rowValues1.AddRange(new[] { "UK", "Anne Dodsworth" });
            List<object> rowValues2 = new List<object>();
            rowValues2.AddRange(new[] { "USA", "Andrew Fuller" });
            List<IList> selectedRows = new List<IList>(new[] { rowValues1, rowValues2 });

            // Create a selection range and specify its minimum and maximum values.
            DateTime minimumValue = new DateTime(2015, 3, 1);
            DateTime maximumValue = new DateTime(2016, 3, 1);
            RangeFilterSelection selectedRange = new RangeFilterSelection(minimumValue, maximumValue);

            // Select the values in the Grid dashboard item.
            dashboardViewer1.SetMasterFilter("gridDashboardItem1", selectedRows);
            // Select the range in the Range Filter dashboard item.
            dashboardViewer1.SetRange("rangeFilterDashboardItem1", selectedRange);
        }

        private void DashboardViewer1_MasterFilterSet(object sender, MasterFilterSetEventArgs e)
        {
            DashboardViewer viewer = (DashboardViewer)sender;
            // If the Master Filter includes Anne Dodsworth as Sales Person, disable print and export.
            if (e.DashboardItemName.Contains("grid"))
                viewer.AllowPrintDashboard = e.SelectedValues.Select(value => value[1].ToString()).Contains("Anne Dodsworth") ? false : true;
        }

        private void DashboardViewer1_MasterFilterCleared(object sender, MasterFilterClearedEventArgs e)
        {
            MessageBox.Show("Selection cleared in the " + e.DashboardItemName + "Master Filter item.");
        }

        private void DashboardViewer1_CustomizeDashboardTitle(object sender, CustomizeDashboardTitleEventArgs e)
        {
            DashboardViewer viewer = (DashboardViewer)sender;

            // Create the command button to set Master Filter.
            DashboardToolbarItem setMasterFilterItem = new DashboardToolbarItem("Set Master Filter",
                new Action<DashboardToolbarItemClickEventArgs>((args) => { SetMasterFilterMethod(); }));
            setMasterFilterItem.Caption = "Set Master Filter";
            e.Items.Insert(0, setMasterFilterItem);
        }

        private void DashboardViewer1_ConfigureDataConnection(object sender, DashboardConfigureDataConnectionEventArgs e)
        {
            ExtractDataSourceConnectionParameters parameters = e.ConnectionParameters as ExtractDataSourceConnectionParameters;
            if (parameters != null)
                parameters.FileName = Path.GetFileName(parameters.FileName);
        }
    }
}
vb
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports System.Collections
Imports DevExpress.DashboardCommon
Imports System.IO
Imports DevExpress.DashboardWin
Imports System.Linq
Imports DevExpress.XtraEditors

Namespace Dashboard_SetMasterFilter

    Public Partial Class Form1
        Inherits XtraForm

        Public Sub New()
            InitializeComponent()
            AddHandler dashboardViewer1.ConfigureDataConnection, AddressOf DashboardViewer1_ConfigureDataConnection
            AddHandler dashboardViewer1.CustomizeDashboardTitle, AddressOf DashboardViewer1_CustomizeDashboardTitle
            dashboardViewer1.LoadDashboard("Dashboard.xml")
            AddHandler dashboardViewer1.MasterFilterSet, AddressOf DashboardViewer1_MasterFilterSet
            AddHandler dashboardViewer1.MasterFilterCleared, AddressOf DashboardViewer1_MasterFilterCleared
        End Sub

        Private Sub SetMasterFilterMethod()
            ' Create a list with values to select in the Grid dashboard item.
            Dim rowValues1 As List(Of Object) = New List(Of Object)()
            rowValues1.AddRange({"UK", "Anne Dodsworth"})
            Dim rowValues2 As List(Of Object) = New List(Of Object)()
            rowValues2.AddRange({"USA", "Andrew Fuller"})
            Dim selectedRows As List(Of IList) = New List(Of IList)({rowValues1, rowValues2})
            ' Create a selection range and specify its minimum and maximum values.
            Dim minimumValue As Date = New DateTime(2015, 3, 1)
            Dim maximumValue As Date = New DateTime(2016, 3, 1)
            Dim selectedRange As RangeFilterSelection = New RangeFilterSelection(minimumValue, maximumValue)
            ' Select the values in the Grid dashboard item.
            dashboardViewer1.SetMasterFilter("gridDashboardItem1", selectedRows)
            ' Select the range in the Range Filter dashboard item.
            dashboardViewer1.SetRange("rangeFilterDashboardItem1", selectedRange)
        End Sub

        Private Sub DashboardViewer1_MasterFilterSet(ByVal sender As Object, ByVal e As MasterFilterSetEventArgs)
            Dim viewer As DashboardViewer = CType(sender, DashboardViewer)
            ' If the Master Filter includes Anne Dodsworth as Sales Person, disable print and export.
            If e.DashboardItemName.Contains("grid") Then viewer.AllowPrintDashboard = If(e.SelectedValues.[Select](Function(value) value(1).ToString()).Contains("Anne Dodsworth"), False, True)
        End Sub

        Private Sub DashboardViewer1_MasterFilterCleared(ByVal sender As Object, ByVal e As MasterFilterClearedEventArgs)
            MessageBox.Show("Selection cleared in the " & e.DashboardItemName & "Master Filter item.")
        End Sub

        Private Sub DashboardViewer1_CustomizeDashboardTitle(ByVal sender As Object, ByVal e As CustomizeDashboardTitleEventArgs)
            Dim viewer As DashboardViewer = CType(sender, DashboardViewer)
            ' Create the command button to set Master Filter.
            Dim setMasterFilterItem As DashboardToolbarItem = New DashboardToolbarItem("Set Master Filter", New Action(Of DashboardToolbarItemClickEventArgs)(Sub(args) SetMasterFilterMethod()))
            setMasterFilterItem.Caption = "Set Master Filter"
            e.Items.Insert(0, setMasterFilterItem)
        End Sub

        Private Sub DashboardViewer1_ConfigureDataConnection(ByVal sender As Object, ByVal e As DashboardConfigureDataConnectionEventArgs)
            Dim parameters As ExtractDataSourceConnectionParameters = TryCast(e.ConnectionParameters, ExtractDataSourceConnectionParameters)
            If parameters IsNot Nothing Then parameters.FileName = Path.GetFileName(parameters.FileName)
        End Sub
    End Class
End Namespace

Inheritance

Object RangeFilterSelection

See Also

RangeFilterSelection Members

RangeFilterDashboardItem

DateFilterDashboardItem

Master Filtering in BI Dashboard

DevExpress.DashboardCommon Namespace