Dynamic Checkbox List

Has anyone successfully created a dynamic checkbox list based off the selection in another filter?

What I am trying to accomplish is to have a drop down list of ‘Markets’ and, based on the market selected, the checkbox list would update to the hospitals in that market. I tried to setup the checkbox list filter as a dependent filter on the Market list, but that didn’t do anything.

I am building out a dashboard where we are comparing certain metrics from a selection of hospitals within a given market, and having a checkbox list is preferred over another drop down list.

Anyone have any good thoughts? Thanks!

I have done this but manually - i.e. from a script on the ‘on selection change’ from the dropdown.

Create a CheckboxListItem with the appropriate values and push it into the checkbox. Then call the onItemsChanged.

I can dig up the script if required

Hi David,

That would be awesome, as long as it isn’t too much trouble. I am still working on being able to do some of this scripting from scratch.

Thank You

I’m using the list to dynamically show items and then when you click another button it runs a process that does things based on the checked items. Not sure how it will work with a filter one. It may work, or you may need to loop through and manually set the filter.

Here’s my code framework

//empty the list
    	parameterCheckboxList1.control.items.length = 0;
    	parameterCheckboxList1.control.onItemsChanged();

//foreach loop or whatever to loop through a list of  'stuff' and add items
    {
        cli = new dundas.controls.CheckboxListItem();
        cli.label = stuff.friendlyName; //this is what shows in the checkbox list
        cli.value = false; //the item is unchecked

    //storing things in 'data'  we can reference to do something based on the checked item
        cli.data.value = something;  
        cli.data.anotherValue= somethingElse; // more things associated with the item

    //stick the item into the list and update
      parameterCheckboxList1.control.items.push(cli);
       parameterCheckboxList1.control.onItemsChanged();
    }

Thank you, I appreciate it. I will play around with this and see what I can come up with.
This seems close to what I want, the only thing I need to try to figure out is how to determine the list of hospitals to display in that checkbox list. I’m sure I will have to loop through something, just not sure yet what that is.

Thanks again

If it’s based on a specific list based on your dropdown selection, you need to have a list of hospitals per market.

There are many ways to do this. You use JavaScript arrays, maps or objects, store them with a separating character in the value of the dropdown or even have an off canvas table. Entirely up to you, it really depends how long the lists are and how often they will change.

NOTE: This is the manual way of doing it. There may be a reason that the dependant filters didn’t work for you and someone might have an idea about that. If that is the case, you don’t need to do all this work.

I wanted to close the loop on this. I was able to get this checkbox list to filter the way I needed using the dependent filters option. I was just missing a field in my dataset to use, once I added the market field, it worked the I was hoping.

1 Like