Monday, 29 May 2017

Hide and collapse child nodes in kendo diagram

can someone help me collapse my nodes in kendo diagram. i want the nodes to be collapsed by default and allow the user to expand the collapsed nodes to see its child nodes.I need a way to collapse my nodes. Thus having the root node and the its first generation child nodes, with the rest of the nodes collapsed.

   function createDiagram(data) {
                $("#diagram").kendoDiagram({
                    dataSource: {
                        data: data,
                        schema: {
                            model: {
                                children: "items"
                            }
                        }
                    },
                    layout: {
                        type: "tree",
                        subtype: "Tipover",
                        horizontalSeparation: 30,
                        verticalSeparation: 20
                    },
                    shapeDefaults: {
                        visual: visualTemplate
                    }
                });
            }



            function addNodes(root, levels) {
                if (levels.length > 0) {
                    for (var i = 0; i < levels[0]; i++) {
                        var node = { name: "0", items: [] };
                        root.items.push(node);

                        addNodes(node, levels.slice(1));
                    }
                }
            }

            $(document).ready(function () {
                $("#subtype").change(function () {
                    $("#diagram").getKendoDiagram().layout({
                        subtype: $(this).val(),
                        type: "tree",
                        horizontalSeparation: 30,
                        verticalSeparation: 20
                    });
                });
            });



via Tapiwa Bosha

No comments:

Post a Comment