How to set view to decision table in web modeler?

Hi,

I have integrated camunda modeler in my angular application and I’m working with DMN tables.

I have been trying to display the DMN table in the decision table view but whenever the page is loaded for the first time then the DMN table is displayed in drd view and the next time when I try to load the table it is loaded in the decision table view.

     ```

ngOnInit() {
// initialize DM Diagram Modeller.

this.dmnDiagramModeler = new DmnModeler({
  keyboard: { bindTo: window },
  drd: {
    additionalModules: [
      propertiesPanelModule,
      propertiesProviderModule,
      drdAdapterModule,
    ],
  },
  moddleExtensions: {
    camunda: camundaModdleDescriptor,
  },
  container: '#dmn-container',
});

// Fires when XML Import into DMN Modeller is complete.
this.dmnDiagramModeler.on('import.done', ({ error, warnings }) => {
  console.log('Import Done event successfully emitted');
  if (!error) {
    try {
      // Draw the DMN model.
      const activeEditor = this.dmnDiagramModeler.getActiveViewer();
      const canvas = activeEditor.get('dmn-container');
      canvas.zoom('fit-viewport');
      activeEditor.attachTo(this.el.nativeElement);
      // DMN Canvas will have multiple views (one view for each decision box/table)
      const view = this.dmnDiagramModeler.getViews()[1];
      this.dmnDiagramModeler.open(view);

      // SWITCHING TABS
      this.dmnDiagramModeler.on(
        'import.render.complete',
        (aNewView, err, wrngs) => {}
      );
    } catch {}
  } else {
    console.log(error);
  }
});

}


How can I ensure that whenever the page is loaded for the first time the table appears in **decision table view** ?

@jonathan.lukas, @Niklas_Kiefer

Hello @Harshit_Dixit ,

one way would be to encapsulate the Viewer in your component and let the DMN always be read-only first.

Then, if the user has the permission to edit, you could insert a button that offers “Edit” and on click opens the editor.

Does this sound reasonable?

Jonathan

Hi @jonathan.lukas,

Thanks for the response.

I found the solution - open-dmn-in-decision-table-view

But I’m getting an error while declaring canvas:
const canvas = activeEditor.get(‘dmn-container’);

Error: No provider for “dmn-container”!

Do you know the cause of this?

Thanks.

Hi, I have found the solution.

Thanks.

1 Like