Get error no provider for x

It seems like my DRD an the decisiontable is perfectly rendered, but wht is this error?

rendered
could not import DMN 1.1 diagram Error: "No provider for "box_saetze_content"! (Resolving: copyPaste -> mouseTracking -> box_saetze_content)"

My code:

var dmnModeler = new DmnJS({
        container: '#box_saetze_content'
    });

function openDiagram(dmnXML)
    {
        dmnModeler.importXML(dmnXML, function(err)
        {
            if (err)
            {
                return console.error('could not import DMN 1.1 diagram', err);
            }
            else
            {
                console.log('rendered');
            }

            var activeEditor = dmnModeler.getActiveViewer();
            var canvas = activeEditor.get('box_saetze_content');
            canvas.zoom('fit-viewport');
        });
    }

    $.get(diagramUrl, openDiagram, 'text');

You’re asking for the service box_saetze_content which does not exist.

Ok, but what should this “service” be? In the starter example there is a div with the id #canvas to which the dmn is bind. So I thought, that in this case the id of the element was ment.

If I change this to canvas I get this error:

could not import DMN 1.1 diagram Error: "No provider for "canvas"! (Resolving: canvas)"

Lets start at the beginning: Please clearly state what you’d like to achieve:

  • What would you like to do?
  • What did you try?
  • What did you expect?
  • What did not work as expected?
  • Where did you get stuck?

Once we know that we have a good indication where to start helping you.

You told me that there is no documentation. So I have to adapt the examples. In the starter Example there is this block included with the zoom fit viewport. I don’t know if I have to define that. If I remove this codeblock the dmn still works - I think.

For what should this be? Could I remove that?
I don’t have a special expectation why I’m using this - only because the example includes it. :slight_smile:

Which starter example do you refer to?

Thanks for the clarification.

The example shows you how to access components within the DmnJS instance. Due to the nature of the library (it essentially hosts a number of different editors, one for each view) we’d actually need to take the active editor into account when fetching internal components.

The following will only work if we’re currently viewing a DRD, which is the case in the example.

var activeEditor = dmnModeler.getActiveViewer();

// access active editor components
var canvas = activeEditor.get('canvas');

// zoom to fit full viewport
canvas.zoom('fit-viewport');

The better way to approach it would be to check for the active view’s type and act accordingly:

var activeView = dmnModeler.getActiveView();

if (activeView.type === 'drd') {
  var activeEditor = dmnModeler.getActiveViewer();

  // access active editor components
  var canvas = activeEditor.get('canvas');

  // zoom to fit full viewport
  canvas.zoom('fit-viewport');
}
1 Like

I updated our starters accordingly.

Ah ok. Thanks a lot for the information.
And for updating the starters. :slight_smile: