CheckBox using Blox without Action Button
Hello everyone,
I have created a Blox widget which shows a list of values with checkboxes.
I am trying to make the check boxes "actionable", meaning that when a checkbox is ticked, then my dashboard filter adjusts.
I have tried to utilize this widget script, but it doesn't seem to work:
widget.on('processresult', function(se, ev){
ev.result.unshift(allObject)
})
widget.on('ready', function(se, ev){
var filterName = 'Chain Name'
var select = document.getElementById(`data.filters[2].filterJaql.members[0]`);
dashboardFilter = prism.activeDashboard.filters.$$items.find(el => el.jaql.title == filterName)
if(dashboardFilter && dashboardFilter.jaql.filter && dashboardFilter.jaql.filter.members)
{
select.value = dashboardFilter.jaql.filter.members[0]
}
select.addEventListener("change", function(e){
if(e.target.value == "All")
{
filter = {
"explicit": false,
"multiSelection": true,
"all": true
}
}else
{
filter = {
"explicit": true,
"multiSelection": true,
"members": [
e.target.value
]
}
}
dashboardFilter = prism.activeDashboard.filters.$$items.find(el => el.jaql.title == filterName)
var filterOptions = {
save: true,
refresh: true,
}
dashboardFilter.jaql.filter = filter
prism.activeDashboard.filters.update(dashboardFilter, filterOptions)
});
})Can anyone help me with this?
Michalis Gregoriou
Posted 1 year ago·Last reply 1 year ago
6 comments
Michalis Gregoriou
OP1 year agoHey JeremyFriedel ,
Thank you for getting back with this wonderful script!
It looks like it's working properly!
The only feedback that I noticed is, when de-selecting all the checkboxes. In the "target" filter it doesn't "return" to the Include all mode.
Is there a way to fine-tune this scenario?
Jeremy Friedel
·1 year agoNo problem Mike, great to hear!
As noted in the first comment this might need some modification to match the specific widget, but this general code example shows how the "Include All" functionality for no boxes checked can be set.
Jeremy Friedel
·1 year agoHi MikeGre
Below is a general example widget script demonstrating this functionality. Some modification may be required to match with the specific Blox template, including updating the dashboard filter title variable and the CSS selectors variable to match the widget's Blox structure and HTML.
Console logging can be enabled or disable via the enableDebugLogging variable.
This script updates the dashboard filter based on checkbox selections. Additional customizations, such as modifying how the selected choice text is processed beyond the full text, can be implemented if needed directly within the script.
The provided solution is self-contained and does not use any external Blox actions or Blox action buttons.
DRay
·1 year agoJeremyFriedel, are you able to help here?
DRay
·1 year agoHi MikeGre.
Thank you for reaching out. I see your question hasn't gotten a response yet, so I'm asking internally to try and get you an answer.
Michalis Gregoriou
OP1 year agoThank you DRay !