Jump to content
We've recently updated our Privacy Statement, available here. ×

Spotfire Javascript API get complete hierarchy filter tree


Vinay Lakkam

Recommended Posts

I understand that there is a way to get checked filters from a checkbox-hierarchy-filter treewith 'spotfire.webPlayer.includedFilterSettings.ALL_WITH_CHECKED_HIERARCHY_NODES' and unchecked filters with `spotfire.webPlayer.includedFilterSettings.ALL_WITH_UNCHECKED_HIERARCHY_NODES` option.

But none of these options gives me a complete hierarchy tree (including its descendants). Is there a way to get such data

Link to comment
Share on other sites

  • 1 year later...

I used the below JS to obtain the heirarchyPaths from the getFilterColumn. I then transform the data to be used in a multiselect drop down menu.

 

 

 

function OnLoadRun(doc, fil_sch, dtname, dcname) {

doc.filtering.getFilterColumn(fil_sch, dtname, dcname, spotfire.webPlayer.includedFilterSettings.ALL_WITH_CHECKED_HIERARCHY_NODES, function(FilterColumn) {

console.log(FilterColumn);

console.log(FilterColumn.filterSettings.hierarchyPaths);

 

var data = FilterColumn.filterSettings.hierarchyPaths

const opt = data.reduce((results, pair) => {

if (!results[0][pair[0]]) //first element of results is lookup map of other elements

results.push(results[0][pair[0]] = {

label: pair[0],

children: []

});

results[0][pair[0]].children.push({

label: pair[1],

value: pair[1],

selected: "TRUE"

});

return results;

}, [{}]).slice(1); //slice off map as it's no longer needed

 

console.log(opt);

 

$('#elem1').multiselect('dataprovider', opt);

$('#elem1').multiselect('refresh');

})

}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...