load

Loads a saved diagram.

Parameters

json Object

The serialized Diagram options to load.

Example - save and load Diagram content

<button id="saveBtn">Save Diagram</button>
<button id="loadBtn">Load Diagram</button>
<div id="diagram"></div>
<script>
  $("#saveBtn").on("click", function(){
    var diagram = $("#diagram").getKendoDiagram();
    localStorage.setItem("diagram", JSON.stringify(diagram.save()));
  });
  $("#loadBtn").on("click", function(){
    var diagram = $("#diagram").getKendoDiagram();
    if(localStorage.getItem("diagram")){
      diagram.load(JSON.parse(localStorage.getItem("diagram")));
    }
  });
  $("#diagram").kendoDiagram({
    layout: {
      type: "layered"
    },
    shapes: [{
      id: "1"
    }, {
      id: "2"
    }, {
      id: "3"
    }],
    connections: [{
      from: "1",
      to: "2"
    },{
      from: "2",
      to: "3"
    }],
    connectionDefaults: {
      endCap: "ArrowEnd"
    }
  });
</script>
In this article
Not finding the help you need? Improve this article