cancel
Showing results for 
Search instead for 
Did you mean: 
OleksandrB
Sisense Team Member
Sisense Team Member

Blox with drop-down and All values in it

Sometimes we need to have an All values option for our dropdown menu in the BLOX. Especially if we just open the dashboard and filter set to Include all.

Screenshot_91.png

 

To create it, press the pencil icon to edit the widget. 

In our case, we have an Item Account from the AD table. Press the 3-dotsdots in the right-up corner and Edit Script.

Screenshot_92.png


Our script will look like

 

const targetDimension = '[AD.Account]';
const allValuesText = 'All Values';

widget.on('ready', function() {

	const filter = widget.dashboard.filters.item(true, targetDimension);
	const checkIncludeAll = $$get(filter, 'jaql.filter.members');

	const filterValue = checkIncludeAll ? checkIncludeAll[0] : allValuesText;

	const prependArg = `<option disabled selected>${filterValue}</option>`;
	$('.dropdownChoices', element).prepend(prependArg);
	if (filterValue !== allValuesText) {
		const includeAllSelectorHolder =  `<option>${allValuesText}</option>`;
		$('.dropdownChoices', element).prepend(includeAllSelectorHolder);
	}

});

 

In the first two rows can change the values for targetDimension we have [AD.Account] it is a Table_name.Column_Name as we have in our widget and allValuesText is a test for All Values.

Press the 'Save' button and enjoy the result.

Disclaimer: This blog post contains one possible custom workaround solution for users with similar use cases. We cannot guarantee that the custom code solution described in this post will work in every scenario or with every Sisense software version. As such, we strongly advise users to test solutions in their environment before deploying them to ensure that the solutions proffered function as desired. To avoid doubt, the content of this blog post is provided to you “as-is” and without warranty of any kind, express, implied, or otherwise, including without limitation any warranty of security and or fitness for a particular purpose. The workaround solution described in this post incorporates custom coding, which is outside the Sisense product development environment and is, therefore, not covered by Sisense warranty and support services.

Rate this article:
Version history
Last update:
‎10-21-2024 10:43 AM
Updated by:
Contributors