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

Problem with remove item from datasource

1 Answer 333 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 20 Jul 2016, 01:45 PM

HI,

In this sample code i try to delete shape by remove item from diagram datasource,

but after the delete the 2 shapes remain in the diagram and in the datasource only 1.

 

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Kendo UI Snippet</title>

    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.common.min.css"/>
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.rtl.min.css"/>
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.silver.min.css"/>
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.mobile.all.min.css"/>

    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="http://kendo.cdn.telerik.com/2016.2.714/js/kendo.all.min.js"></script>
</head>
<body>
  
<div id="diagram"></div>
<script>
$("#diagram").kendoDiagram({
    dataSource: [{
       "name": "Telerik",
       "items": [
           {"name": "Kendo"},
           {"name": "Icenium"}
       ]
    }],
    template: "#= item.name #",
    autoBind: false
});

// Fetching data will trigger "change" on the dataSource
$("#diagram").getKendoDiagram().dataSource.fetch();
  
var datasource = $("#diagram").getKendoDiagram().dataSource.data()[0];

  alert(datasource.items.length); //2
$("#diagram").getKendoDiagram().dataSource.remove(datasource.items[0]);
  
  alert(datasource.items.length); //1
  
</script>
</body>
</html>

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 22 Jul 2016, 11:24 AM
Hi Daniel,

Calling the diagram's refresh() method will force the rebinding of the diagram with the changed datasource. You can find the updated version of your sample here: http://dojo.telerik.com/@veselinar/eYaKO

Regards,
Vessy
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Diagram
Asked by
Daniel
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or