Add Row to DMN Table programmatically

Hi, I am trying to use the DMN Modeler in an React App.
I can already display and edit data.
Next I would like to change values, add and remove rows programmatically (for example to build an import function from external sources).
Unfortunately I can’t get it to work.

Current code is:

let views = modeler.getViews();
        const decisionTableViews = views.filter(
            ({ type }) => type === 'decisionTable'
        );
        let modeling = modeler.getActiveViewer().get('modeling');

        let row1 = modeling.addRow({ id: 'row1', cells: [{}, {}, {}] }, 2);

But this leads to "Uncaught (in promise) Error: cannot guess "

Is that the right function? What else does it need as an input? Can someone post an example of how to use the addRow?

Thanks and best regards
Christian

Hi,

your addRow call is missing a type attribute. check out dmn-js/packages/dmn-js-decision-table/src/features/editor-actions/DecisionTableEditorActions.js at master · bpmn-io/dmn-js · GitHub on how the TableEditorActions are implemented.

If you want to populate the cells, check out the syntax in this Test Case.

for example to build an import function from external sources

Depending on you use-case, this can also be achieved by just calling viewer.open again, with the new dmn file.

Hope this helps :slightly_smiling_face:

That works for creating a blank row, thanks a lot.
Unfortunately now I have a problem creating the cells inside the row element to complete my import functionality.
Where can I import the dmnFactory Module to create the businessObjects?
Or is there an easier way to just fill textvalues into the cells on rowAdd ?

Thanks