Back to Devexpress

Drill-Down

dashboard-15703-winforms-dashboard-winforms-designer-create-dashboards-in-the-winforms-designer-interactivity-drill-down.md

latest10.2 KB
Original Source

Drill-Down

  • Jul 09, 2021
  • 4 minutes to read

Dashboard provides the Drill-Down feature, which allows end-users to change the detail level of data displayed in a dashboard item. The Drill-Down feature enables users to drill down to display detail data, or drill up to view more general information.

Note

To learn how end-users can drill down using a particular dashboard item, see the Interactivity section for this item.

Enable Drill-Down

Drill-down requires that the data section contains several dimensions…

… or a hierarchy data item (in OLAP mode).

To enable drill-down, click the Drill-Down button in the Data Ribbon tab (or the button if you are using the toolbar menu).

To enable drill-down in code, use the DashboardItemInteractivityOptions.IsDrillDownEnabled property. To access the DashboardItemInteractivityOptions object, use the dashboard item’s InteractivityOptions property.

Note

If the selected dashboard item contains several types of elements that can be used for drill-down, the Ribbon or Toolbar will provide the appropriate buttons to switch between these types (e.g., Arguments and Series buttons in a Chart). For details, refer to the documentation for the individual dashboard items in the Dashboard Item Settings topic.

The following dashboard items support the Drill-Down feature.

Perform Drill-Down

The DashboardDesigner.GetAvailableDrillDownValues method allows you to obtain values that can be used to perform drill-down.

To perform drill-down/drill-up in code, use the DashboardDesigner.PerformDrillDown/DashboardDesigner.PerformDrillUp methods.

After drill-down (or drill-up) is performed in the Dashboard Designer, the DashboardDesigner.DrillDownPerformed (or DashboardDesigner.DrillUpPerformed) event is raised.

You can use the DrillActionEventArgs.DrillDownLevel event parameter to determine the current drill-down level.

The DrillActionEventArgs.Values property allows you to obtain values from the current drill-down hierarchy.

Note

In OLAP mode, the DrillActionEventArgs.Values property returns unique names instead of values.

Example

The following code snippets show how to perform a drill-down in DashboardViewer.

In this example, the DashboardViewer.PerformDrillDown method performs a drill-down for a specified row in a Grid dashboard item. The combo box’s SelectedIndexChanged event handler calls the method.

Click the button to call the DashboardViewer.PerformDrillUp method to return to the top detail level.

vb
Imports System
Imports System.Collections.Generic
Imports DevExpress.XtraEditors
Imports System.Collections
Imports DevExpress.DashboardCommon
Imports DevExpress.DashboardCommon.ViewerData

Namespace Dashboard_PerformDrillDown
    Partial Public Class Form1
        Inherits XtraForm

        Public Sub New()
            InitializeComponent()
            AddHandler comboBox1.SelectedIndexChanged, AddressOf comboBox1_SelectedIndexChanged
            AddHandler btnDrillUp.Click, AddressOf btnDrillUp_Click
            ' Loads a dashboard from an XML file.
            dashboardViewer1.LoadDashboard("..\..\Data\Dashboard.xml")
            ' Obtains values that can be used to perform drill-down.
            Dim drillDownValues = dashboardViewer1.GetAvailableDrillDownValues("gridDashboardItem1")
            For Each rows As AxisPointTuple In drillDownValues
                comboBox1.Items.Add(rows.GetAxisPoint().Value)
            Next rows
        End Sub

        Private Sub comboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
            Dim comboBox1 As System.Windows.Forms.ComboBox = DirectCast(sender, System.Windows.Forms.ComboBox)
            If dashboardViewer1.CanPerformDrillDown("gridDashboardItem1") = True Then
                ' Performs drill-down for a selected category.
                dashboardViewer1.PerformDrillDown("gridDashboardItem1", comboBox1.SelectedItem)
            Else
                ' Returns to the previous detail level and  
                ' performs drill-down for the selected category.
                dashboardViewer1.PerformDrillUp("gridDashboardItem1")
                dashboardViewer1.PerformDrillDown("gridDashboardItem1", comboBox1.SelectedItem)
            End If
        End Sub

        Private Sub btnDrillUp_Click(ByVal sender As Object, ByVal e As EventArgs)
            If dashboardViewer1.CanPerformDrillUp("gridDashboardItem1") = True Then
                ' Performs a drill-up in the grid dashboard item.
                dashboardViewer1.PerformDrillUp("gridDashboardItem1")
            Else
                XtraMessageBox.Show("Drill-up is not possible at the current detail level")
            End If
        End Sub
    End Class
End Namespace
csharp
using System;
using System.Collections.Generic;
using DevExpress.XtraEditors;
using System.Collections;
using DevExpress.DashboardCommon;
using DevExpress.DashboardCommon.ViewerData;

namespace Dashboard_PerformDrillDown {
    public partial class Form1 : XtraForm {
        public Form1() {
            InitializeComponent();
            comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
            btnDrillUp.Click += btnDrillUp_Click;
            // Loads a dashboard from an XML file.
            dashboardViewer1.LoadDashboard(@"..\..\Data\Dashboard.xml");
            // Obtains values that can be used to perform drill-down.
            var drillDownValues = dashboardViewer1.GetAvailableDrillDownValues("gridDashboardItem1");
            foreach (AxisPointTuple rows in drillDownValues) {
                comboBox1.Items.Add(rows.GetAxisPoint().Value);
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) {
            System.Windows.Forms.ComboBox comboBox1 = (System.Windows.Forms.ComboBox) sender;
            if (dashboardViewer1.CanPerformDrillDown("gridDashboardItem1") == true) {
                // Performs drill-down for a selected category.
                dashboardViewer1.PerformDrillDown("gridDashboardItem1", comboBox1.SelectedItem);
            }
            else {
                // Returns to the previous detail level and  
                // performs drill-down for the selected category.
                dashboardViewer1.PerformDrillUp("gridDashboardItem1");
                dashboardViewer1.PerformDrillDown("gridDashboardItem1", comboBox1.SelectedItem);
            }
        }

        private void btnDrillUp_Click(object sender, EventArgs e) {
            if (dashboardViewer1.CanPerformDrillUp("gridDashboardItem1") == true) {
                // Performs a drill-up in the grid dashboard item.
                dashboardViewer1.PerformDrillUp("gridDashboardItem1");
            }
            else XtraMessageBox.Show("Drill-up is not possible at the current detail level");
        }
    }
}