This is a migrated thread and some comments may be shown as answers.

Diagram create shape error

1 Answer 60 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
marksist
Top achievements
Rank 1
marksist asked on 13 Aug 2020, 08:51 PM

Hi,

My code : 

<div id="diagram"></div>
<script>
  var dataSource = new kendo.data.HierarchicalDataSource({
    data: [{
      "name": "Progress",
      "items": [
        {"name": "Kendo UI",
         "items":[
           {"name": "TreeList"},
           {"name": "Chart"}
         ]
        },
        {"name": "NativeScript"}
      ]
    }],
    schema: {
      model: {
        children: "items"
      }
    }
  });
  $("#diagram").kendoDiagram({
    dataSource: dataSource,
    editable : {
      tools : [
        { name : "createShape" }
      ]
    },
    layout: {
      type: "tree",
      subtype: "down"
    },
    shapeDefaults: {
      type: "circle",
      content: {
        template: "#= name #"
      },
      width: 80,
      height: 80,
      hover: {
        fill: "Orange"
      }
    },
    connectionDefaults: {
      stroke: {
        color: "#979797",
        width: 1
      },
      type: "polyline",
      startCap: "FilledCircle",
      endCap: "ArrowEnd"
    }
  });

 

When you press add, you can see the error details from the console, how can I solve it?

 

app.js:35020 Uncaught TypeError: Cannot set property 'element' of undefined
    at init.createShape (app.js:35020)
    at init.createShape (app.js:35022)
    at init.click (app.js:35022)
    at init.proxy (app.js:34131)
    at init.trigger (app.js:34387)
    at init._buttonClick (app.js:34690)
    at init.proxy (app.js:34131)
    at init.trigger (app.js:34387)
    at init._click (app.js:34454)
    at HTMLAnchorElement.arguments.length.arguments.<computed>.indexOf.t.<computed>.t.<computed>.options.t.<computed> (app.js:34388)
createShape @ app.js:35020
createShape @ app.js:35022
click @ app.js:35022
proxy @ app.js:34131
trigger @ app.js:34387
_buttonClick @ app.js:34690
proxy @ app.js:34131
trigger @ app.js:34387
_click @ app.js:34454
arguments.length.arguments.<computed>.indexOf.t.<computed>.t.<computed>.options.t.<computed> @ app.js:34388
dispatch @ app.js:28789
elemData.handle @ app.js:28593

1 Answer, 1 is accepted

Sort by
0
Silviya Stoyanova
Telerik team
answered on 17 Aug 2020, 12:30 PM

Hello,

thank you for the provided code snippet!

In order to add shapes and tools to a Diagram, you will need to set the DataSource configuration for CRUD operations.

You could use the following Demo as a reference:

Kind Regards,
Silviya Stoyanova
Progress Telerik

Tags
Diagram
Asked by
marksist
Top achievements
Rank 1
Answers by
Silviya Stoyanova
Telerik team
Share this question
or