Skip to main content

DashboardItemState.MasterFilterValues Property

Gets or sets selected master filter values stored in a dashboard state.

Namespace: DevExpress.DashboardCommon

Assembly: DevExpress.Dashboard.v24.1.Core.dll

NuGet Package: DevExpress.Dashboard.Core

Declaration

public List<object[]> MasterFilterValues { get; set; }

Property Value

Type Description
List<Object[]>

A list of object arrays that specify selected master filter values.

Remarks

Set Master Filter Values

To set master filter values (for example, a row in a Grid), create an object with an array of elements where each element is a dimension value. A number of values in the array should be the same as a number of dimensions to explicitly identify the master filter value. Values order is based on dimensions order.

View Example: How to specify a default dashboard state in code

The example illustrates how to set the master filter value if a dashboard item contains several dimensions for the ASP.NET Web Forms platform. In this example, the Grid contains two dimension columns: State and Category. To define the Grid item row, add an array with two values, for instance, “Utah” and “Bikes”.

using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using System;
using System.Collections.Generic;

namespace WebDashboard_ManualDashboardState {
    public partial class Default : System.Web.UI.Page
    {

        DashboardState dashboardState = new DashboardState();
        protected void Page_Load(object sender, EventArgs e) {
            ASPxDashboard1.SetInitialDashboardState += ASPxDashboard1_SetInitialDashboardState;
        }

        protected void ASPxDashboard1_SetInitialDashboardState(object sender, SetInitialDashboardStateEventArgs e) {
            var state = new DashboardState();
            var itemState = new DashboardItemState("gridSalesByState");
            itemState.MasterFilterValues.Add(new object[] { "Utah", "Bikes" });
            state.Items.Add(itemState);
            e.InitialState = state;
        }
    }
}

Implement the IDashboardStateService interface to manage dashboard state for ASP.NET MVC / ASP.NET Core platforms.

The following code snippet illustrates how to specify a dashboard state (such as master filter or parameter values) in code and how to apply this state when loading a dashboard for the first time. In this example, the DashboardState object holds the required dashboard state. The ASPxDashboard.SetInitialDashboardState event is used to apply the specified dashboard state when loading a dashboard.

using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using System;
using System.Collections.Generic;

namespace WebDashboard_ManualDashboardState
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e) {
        }

        protected void ASPxDashboard1_SetInitialDashboardState(object sender, SetInitialDashboardStateEventArgs e) {
            e.InitialState = InitializeDashboardState();
        }

        public DashboardState InitializeDashboardState() {
            DashboardState dashboardState = new DashboardState();

            DashboardParameterState parameterState = 
                new DashboardParameterState("countryParameter", "USA", typeof(string));

            DashboardItemState gridFilterState = new DashboardItemState("gridDashboardItem1");
            gridFilterState.MasterFilterValues.AddRange(new List<object[]>() {
                new string[1] { "Andrew Fuller" },
                new string[1] { "Laura Callahan" }
            }
            );

            DashboardItemState treemapDrilldownState = new DashboardItemState("treemapDashboardItem1");
            treemapDrilldownState.DrillDownValues.Add("Beverages");

            DashboardItemState rangeFilterState = new DashboardItemState("rangeFilterDashboardItem1");
            rangeFilterState.RangeFilterState.Selection = 
                new RangeFilterSelection(new DateTime(2015, 1, 1), new DateTime(2016, 1, 1));

            dashboardState.Parameters.Add(parameterState);
            dashboardState.Items.AddRange(new List<DashboardItemState>() {
                gridFilterState,
                treemapDrilldownState,
                rangeFilterState }
            );
            return dashboardState;
        }
    }
}

Clear Master Filter Values

To clear filters (unselect all values) of dashboard items, assign an empty array of objects to the MasterFilterValues property:

protected void ASPxDashboard1_SetInitialDashboardState(object sender, SetInitialDashboardStateEventArgs e) {
    var state = new DashboardState();
    // ...
    var itemState = new DashboardItemState("comboBoxDashboardItem");
    itemState.MasterFilterValues = new List<object[]>() { };
    state.Items.Add(itemState);
    // ...
    e.InitialState = state;
} 

When you try to set a dashboard state in WinForms/WPF and the neutral filter mode is disabled (UseNeutralFilterMode == false), for the multiple master filter mode there is a difference between null and empty master filter values:

MasterFilterValues values

Behavior

MasterFilterValues = null

The control filters data by all values (all values are selected).

MasterFilterValues = []

The control excludes all filter (no data is selected).

See the following topics for details on how to assign a dashboard state to a Dashboard control:

See Also