Skip to main content

RangeFilterState Class

A state of the Range Filter and Date Filter dashboard items.

Declaration

export class RangeFilterState

Remarks

The code below shows how to specify a predefined period (6 months) to a Range Filter when you set a dashboard state.

Note

The control variable in the example below is the obtained DashboardControl instance. Refer to the following topic for information on how to obtain a DashboardControl for each platform: Web Dashboard - Client-Side Specifics.

function onClick() {
  //...
  control.setDashboardState({
      "Items": {
          "range": {
              RangeFilterState: {
                  PeriodName: "6 Months"
              }
          }
      }
  });
}

The code below shows how to apply a custom period (from January, 2017 to June, 2018) to a Range Filter when you set a dashboard state:

function onClick() {
  //...
  control.setDashboardState({
      "Items": {
          "range": {
              RangeFilterState: {
                  Selection: {
                      Minimum: new Date(2017, 0, 1),
                      Maximum: new Date(2018, 5, 1)
                  }
              }
          }
      }
  });
}

The code below clears states of the Range Filter and Date Filter dashboard items:

function onClick() {
  //...
  var state = JSON.parse(control.getDashboardState());
  if (state && state.Items) {
      Object.keys(state.Items).forEach(function (itemName) {
          var itemState = state.Items[itemName];
          itemState.RangeFilterState = { };
      }) 
  }
  control.setDashboardState(JSON.stringify(state));

Use the DashboardControl.setDashboardState method to apply a dashboard state to the loaded dashboard.

Properties

PeriodName Property

Specifies the name of the available predefined periods.

Declaration

PeriodName?: string

Property Value

Type Description
string

A string that specifies the name of the available predefined periods.

Remarks

You can use the ViewerApiExtension.getAvailablePredefinedRanges method to get names of the predefined ranges available for the specified Range Filter / Date Filter.

Selection Property

Specifies the selected range in the Range Filter dashboard item.

Declaration

Selection?: RangeFilterSelection

Property Value

Type Description
RangeFilterSelection

A RangeFilterSelection object that specifies the selected range in the Range Filter dashboard item.