Open DMN in Decision Table View

The dmn-js Modeler and Viewer defaults to DRD view even if there is only a single DMN table. Is there a way to open the viewer in Decision Table view in javascript?

dmn-js opens the first element that can be viewed once the import is done. Typically, this is the DRD. You can change that behavior:

dmnJS.importXML(dmnXML, function (err) {
  const views = dmnJS.getViews();

  const decisionTableViews = views.filter(
    ({ type }) => type === "decisionTable"
  );

  if (decisionTableViews.length === 1) {
    dmnJS.open(decisionTableViews[0]);
  }
});

CodeSandbox: https://codesandbox.io/s/open-single-decision-table-by-default-n4j5c

1 Like