BALKANGraph / FamilyTreeJS

Build family tree app with BALKAN FamilyTreeJS library. Family Tree also called a genealogy or a pedigree chart, is a chart representing family relationships in a conventional tree structure.
60 stars 17 forks source link

How delete node with node menu? #65

Closed ahvahsky2008 closed 10 months ago

ahvahsky2008 commented 1 year ago

How delete node?

<script src="https://balkan.app/js/familytree.js"></script> 
<div id="tree"/>
<script>

var family = new FamilyTree(document.getElementById("tree"), {
    mouseScrool: FamilyTree.action.none,
    miniMap: true,
    nodeTreeMenu: true,
    nodeMenu: {
        edit: { text: "Edit" },
        remove: {text: "delete",
                    onClick:  function (sender, args){
                        var node = family.getNode(sender);
                        family.remove(node); // it doesn't work
                    }},
    },
    nodeBinding: {
        field_0: "name"
    },
    nodes: [
        { id: 1, pids: [2], name: "Amber McKenzie", gender: "female" },
        { id: 2, pids: [1], name: "Ava Field", gender: "male" },
        { id: 3, mid: 1, fid: 2, name: "Peter Stevens", gender: "male" }
    ]
});
</script>
ZornitsaPesheva commented 1 year ago

Created a code demo for you: https://code.balkan.app/family-tree-js/remove-(delete)-node-from-nodemenu#JS