I'm looking for ways to hide certain dashboard filters based on their title name. Is there a way to do the same? Also, the filters will be added as dependent. For e.g. we can have these 4 dependent filters Filter1 >> Filter2 >> Filter_3 >> Filter4 and we need to hide the one with an underscore in its name.
You can try the following dashboard script that works with dependent filters:
const filterToHide = 'Month'
dashboard.on('initialized', (d, args) => {
let depFilterPos, filterPos, k
for (let i = 0; i < d.filters.$$items.length; i++) {
let filter = d.filters.$$items[i]
if (!defined(filter.levels)) { continue }
for (let j = 0; j < filter.levels.length; j++) {
let level = filter.levels[j]
if (level.title === filterToHide) {
depFilterPos = i + 2
filterPos = j + 1
}
}
}
console.log(depFilterPos, filterPos)
var styles = `
.ew-panel > .f-wrapper:nth-child(${depFilterPos}) > .ew-item > .f-group > .f-mini-host:nth-child(${filterPos}) {
display: none;
}
`
var styleSheet = document.createElement("style")
styleSheet.innerText = styles
document.head.appendChild(styleSheet)
})
What the above is doing is searching for the filterToHide title in dependent filters in the filters panel. It then records the 'dependent filter index' and 'filter index' so that we can change the CSS for this element as display: none.
This worked on my side in a limited testing scenario. You will need to refresh the dashboard if any changes are made to the filter shelf order.
I know it's been a while, but I’m following up to see if the solution offered by rapidbisupport worked for you.
If so, please click the 'Accept as Solution' button on their post. That way other users with the same questions can find the answer. If not, please let us know so that we can continue to help.
HI DRay, this solution doesn't work for us as we are using iFrame embedding and this will get blocked by browser security. How would you securely share via WAT embedding and hide the filters to prevent people from toggle off the filter and access more data than they should?