Script for Template

Hello everyone,


I want to allow the user to use two templates in one report.

I want to create a button with script, click on it will replace the templet

Does anyone have a solution?


Thanks!

Here is a sample script that you can use with the Click action to replace a template:


var canvasService = this.getService("CanvasService");

var canvasAdapter = canvasService.canvasAdapter;

var dashboardService = this.getService("DashboardService");

var promise = dashboardService.getDashboardById("bf17833a-4d6f-44c5-bd41-1b2b97920f88"); // use your template dashboard id that you want to set

promise.done(function(obj){

var templateEntity = dundas.Utility.cloneAdapter(obj);

var templateAdapter = new dundas.view.controls.Dashboard({ control: templateEntity });

// First clear the current template

canvasService.clearTemplate();

// Now load the new template

canvasService.loadTemplate(templateAdapter);

});


Depending on your use case, you may also explore other ways:

  • Expand/collapse a template grid cell. Here is an article that describes the overall process.
  • Use multiple layers in the template and switch between them using a Change Layer interaction (relevant article).