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

How to load diagram programatically?

3 Answers 185 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Kamil
Top achievements
Rank 1
Kamil asked on 03 Jul 2015, 04:17 PM

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?

3 Answers, 1 is accepted

Sort by
0
Kamil
Top achievements
Rank 1
answered on 03 Jul 2015, 04:20 PM
Meaning: when I click on the seperate button, not on the diagram
0
Kamil
Top achievements
Rank 1
answered on 07 Jul 2015, 09:17 AM

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);

}

0
Daniel
Telerik team
answered on 07 Jul 2015, 10:12 AM
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
Tags
Diagram
Asked by
Kamil
Top achievements
Rank 1
Answers by
Kamil
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or