Articles in this section

How to Retrieve Master Widget Filter Values in Bold BI Custom Widgets

Published:

This article provides guidelines on how to retrieve selected values from master widgets and use them within custom widgets in Bold BI.

Use case:

In some scenarios, you may need to check whether any values are selected in a master widget and trigger specific actions in a custom widget based on those selections (for example, executing logic only when filters are applied).

Steps to Retrieve Master Widget Instance and Filter Values
1. Get the Unique Name

To access a master filter widget, you need its unique identifier:

Navigate to the widget property panel and get the value from the “Unique Name” property

unique_name.png

2. Pass the Unique Name to Custom Widget

Add a custom property to the custom widget and specify the unique identifier of the master filter widget. For example, the “Identifier of the Case ID Filter” is added as a custom property, as shown in the image below.

Paste the unique name of the master widget into this property. In Step 1, comboBox1 was identified as the unique name of the master filter widget

UniqueNameinCustomWidget.png

3. Retrieve the Dashboard Instance
this.designId = bbdesigner$(this.element)
   .closest(".e-customwidget-item")
   .attr("id")
   .split("_" + this.model.widgetId)[0];

this.dashboardInstance = bbdesigner$("#" + this.designId)
   .data('BoldBIDashboardDesigner'); 
4. Get the Master Widget Instance
this.masterWidgetInstance = this.model.properties.masterWidgetIdetifier!= ''
   ? this.dashboardInstance.modules.util.getWidgetInstanceByGuid(this.model.properties.filterNodeText) 
   : ''; 

masterWidgetIdetifier → Stores the unique name of the master widget.
For example, in step 3, comboBox1 is the unique name of the master widget stored in this variable at the backend (i.e., defined in the widget.json file).

Note: The masterWidgetIdentifier is the property name (backend) corresponding to the identifier of the Case ID filter in the UI.

getWidgetInstanceByGuid() → Retrieves the corresponding widget instance based on the unique name of the master widget.

5. Access Filter / Selected Values

Once you have the widget instance, you can:

  • Check if filters are applied

Use the following code:

if (instance != "" && instance.widgetJson.SelectedFilterValues.length > 0) {

   for (var i = 0; i < instance.widgetJson.SelectedFilterValues.length; i++) {
       if (instance.widgetJson.SelectedFilterValues[i].ReportName == this.model.properties.filterNodeText) {
           var filterValue = instance.widgetJson.SelectedFilterValues[i].InitialDimensionFilter.Text;
           this.combofilter = Array.isArray(filterValue) ? filterValue.join(",") : filterValue;
       }
   }
} 
  • Retrieve selected values

selectedValues.png

  • Perform custom logic
   if (combofilter) {
       // Perform your action
   }
} 
Summary:
  • Use the Unique Name to identify the master widget
  • Pass the Unique Name to the custom widget via properties
  • Use getWidgetInstanceByGuid() to fetch the widget instance
  • Access filter values and implement custom logic

Using this approach, you can obtain the filtered values from the master widget and implement custom logic or actions in the custom widget based on those values.

Additional References:

How to create a new custom widget

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
VP
Written by Vaishnavi Panchatcharam
Updated:
Comments (0)
Access denied
Access denied