Problem with remove item from datasource

2 posts, 0 answers
  1. Daniel
    Daniel avatar
    1 posts
    Member since:
    Nov 2012

    Posted 20 Jul Link to this post

    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>

  2. Vessy
    Admin
    Vessy avatar
    1382 posts

    Posted 22 Jul Link to this post

    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.
     
  3. Kendo UI is VS 2017 Ready
Back to Top