How set the toggle template cell to collapse on load via script

Hi,

I have a requirement to have the toggle template cell to expand and collapse. How can I set the template cell to collapse on load?

Regards,

Renzi

Hi Renzi, you can toggle template cell on the ready event instead of load as follows

  1. Create a dashboard with the template grid and place the elements as required
  2. Add a button and set Toggle template cell action on it. Place the button in the cell, which you want to collapse and expand on the click. You can have this button hidden by hiding using Layout properties
  3. Click outside the dashboard canvas
  4. Add below script in the dashboard’s ready event and view the dashboard in Sandbox mode

Note: Please check the name of the button from button properties panel

// Get Adapter by Name

var

canvasService = dundas.context.getService(“CanvasService”);

//Replace the button name “button1” with the actual button name from properties panel

var otherViewModel = canvasService.getViewModelByName(“button1”);

//Trigger the Click Action

var

otherAdapter = otherViewModel.businessObject;

$(otherAdapter.container).tapClick();

Hope this helps!

1 Like

Thanks. This solution worked for me.

1 Like