How to load diagram programatically?

4 posts, 0 answers
  1. Kamil
    Kamil avatar
    3 posts
    Member since:
    Jun 2015

    Posted 03 Jul 2015 Link to this post

    Hello

        Perhaps telerik diagrams are quite good, but I can't find out how to reload a diagram?

    I have a diagram like this:

     

    @(Html.Kendo().Diagram()
                  .Name("diagram")
                  .DataSource(dataSource => dataSource
                  .Read(read => read
                              .Action("GetLinkedPersonsData", "KartotekaKlientow")
                  )
                  .Model(m => m.Children("Items"))
                  )
                  .Editable(false)
                  .Layout(l => l.Type(DiagramLayoutType.Layered))
                  .ShapeDefaults(sd => sd
                          .Visual("LinkedPersonsTemplate")
                  )
                  .ConnectionDefaults(cd => cd
                  .Stroke(s => s
                  .Color("#979797")
                  .Width(2)
                  )
                  )
    )

    and when I click I want the diagram to reload and get new data without refreshing the page. It would be also solution to inject new data into diagram. 

    Is there any way to to any of these?

  2. Kamil
    Kamil avatar
    3 posts
    Member since:
    Jun 2015

    Posted 03 Jul 2015 in reply to Kamil Link to this post

    Meaning: when I click on the seperate button, not on the diagram
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Kamil
    Kamil avatar
    3 posts
    Member since:
    Jun 2015

    Posted 07 Jul 2015 in reply to Kamil Link to this post

    Ok, problem solved. I had to use javascript method and do it as follows:

    function createDiagram(dataToList) {

        var data = dataToList;


        $("#diagram").kendoDiagram({
            dataSource: new kendo.data.HierarchicalDataSource({
                data: data,
                schema: {
                    model: {
                        children: "Items"
                    }
                }
            }),
            layout: {
                type: "layered"
            },
            shapeDefaults: {
                visual: LinkedPersonsTemplate
            },
            connectionDefaults: {
                stroke: {
                    color: "#979797",
                    width: 2
                }
            }
        });

        var diagram = $("#diagram").getKendoDiagram();
        diagram.bringIntoView(diagram.shapes);

    }

  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 07 Jul 2015 Link to this post

    Hello,

    You can reload the data from the server by using the diagram dataSource.read method. If you wish to set new data via JavaScript then you can use the dataSource.data method.

    Regards,
    Daniel
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready