Blox with drop-down and All values in it
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.
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.
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 post outlines a potential custom workaround for specific use cases. The solution may not work in all scenarios or Sisense versions, so we strongly recommend testing it in your environment before deployment. The content is provided "as-is" without any warranty, including security or fitness for a particular purpose. Custom coding is involved, which falls outside Sisense's warranty and support.
Related Content:
https://academy.sisense.com/master-class-advanced-dashboards-with-plug-ins-and-scripts
https://docs.sisense.com/main/SisenseLinux/customizing-sisense-using-code.htm