cancel
Showing results for 
Search instead for 
Did you mean: 

Code example using Blox dropdown to select dashboards

jeffreyl
8 - Cloud Apps
8 - Cloud Apps

I have been searching the web for a couple of days with no success. I need a code example using Blox dropdown to select dashboards. I have 10 regional locations, each will have a set of dashboards. I am able to create and use 10 buttons on a dashboard but it would be cleaner and better if I can use a dropdown to open the url and go to the selected regional dashboard. I am thinking I need to use an Action Set but have not figured out how to make it work with a Blox dropdown or a radio button. I have found dropdown filter examples but have not been able to translate that to calling the action goto url.

1 ACCEPTED SOLUTION

harikm007
13 - Data Warehouse
13 - Data Warehouse

Hi @jeffreyl ,

Try this blox script:

1.  Create blox using below script (replace Dasboard1 URL and Dashboard2 URL with actual URLs):

 

 

{
    "style": {},
    "script": "",
    "title": "",
    "titleStyle": [
        {
            "display": ""
        }
    ],
    "showCarousel": true,
    "carouselAnimation": {
        "showButtons": false
    },
    "body": [
        {
            "type": "Container"
        },
        {
            "type": "ColumnSet",
            "separator": false,
            "spacing": "default",
            "columns": [
                {
                    "type": "Column",
                    "width": "170px",
                    "items": [
                        {
                            "type": "TextBlock",
                            "size": "small",
                            "weight": "regular",
                            "wrap": true,
                            "class": "checkboxVal",
                            "text": "Choose Dasbhoard"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "spacing": "none",
                    "width": "175px",
                    "items": [
                        {
                            "type": "Container",
                            "spacing": "none",
                            "items": [
                                {
                                    "type": "Input.ChoiceSet",
                                    "id": "selectVal",
                                    "class": "",
                                    "displayType": "compact",
                                    "value": "",
                                    "choices": [
                                        {
                                            "title": "Dasboard1",
                                            "value": "Dasboard1 URL"
                                        },
                                        {
                                            "title": "Dashboard2",
                                            "value": "Dashboard2 URL"
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                },
                {
                    "type": "Column",
                    "spacing": "none",
                    "width": "175px",
                    "items": [
                        {
                            "type": "Container",
                            "spacing": "none",
                            "items": [
                                {
                                    "type": "ActionSet",
                                    "actions": [
                                        {
                                            "type": "openDashboardAction",
                                            "title": "Open"
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ],
    "actions": []
}

 

 

2. Create an action 'openDashboardAction' with below script:

 

 

dashboardURL = payload.data.selectVal
window.open(dashboardURL, '_blank').focus();

 

-Hari

 

View solution in original post

2 REPLIES 2

harikm007
13 - Data Warehouse
13 - Data Warehouse

Hi @jeffreyl ,

Try this blox script:

1.  Create blox using below script (replace Dasboard1 URL and Dashboard2 URL with actual URLs):

 

 

{
    "style": {},
    "script": "",
    "title": "",
    "titleStyle": [
        {
            "display": ""
        }
    ],
    "showCarousel": true,
    "carouselAnimation": {
        "showButtons": false
    },
    "body": [
        {
            "type": "Container"
        },
        {
            "type": "ColumnSet",
            "separator": false,
            "spacing": "default",
            "columns": [
                {
                    "type": "Column",
                    "width": "170px",
                    "items": [
                        {
                            "type": "TextBlock",
                            "size": "small",
                            "weight": "regular",
                            "wrap": true,
                            "class": "checkboxVal",
                            "text": "Choose Dasbhoard"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "spacing": "none",
                    "width": "175px",
                    "items": [
                        {
                            "type": "Container",
                            "spacing": "none",
                            "items": [
                                {
                                    "type": "Input.ChoiceSet",
                                    "id": "selectVal",
                                    "class": "",
                                    "displayType": "compact",
                                    "value": "",
                                    "choices": [
                                        {
                                            "title": "Dasboard1",
                                            "value": "Dasboard1 URL"
                                        },
                                        {
                                            "title": "Dashboard2",
                                            "value": "Dashboard2 URL"
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                },
                {
                    "type": "Column",
                    "spacing": "none",
                    "width": "175px",
                    "items": [
                        {
                            "type": "Container",
                            "spacing": "none",
                            "items": [
                                {
                                    "type": "ActionSet",
                                    "actions": [
                                        {
                                            "type": "openDashboardAction",
                                            "title": "Open"
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ],
    "actions": []
}

 

 

2. Create an action 'openDashboardAction' with below script:

 

 

dashboardURL = payload.data.selectVal
window.open(dashboardURL, '_blank').focus();

 

-Hari

 

Great response. Had a couple questions:

1) How did you know that you have to set "displayType":"compact" to get a dropdown to render correctly? The only place that I see that in the Blox documentation is in the one code sample for Dynamic Inputs. In the docs for "Dropdown", all it says is that it's id has to be "selectVal".
2) What do you do if you want more than one dropdown? ie. what is the id? The documentation says that it has to be "selectVal", yet in my tests, using just "type", and "displayType" are enough to force a render to a dropdown.