Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Place a node(object) left corner of each row of nodes created with TreeModel

$
0
0

@rahimhaji wrote:

Dear Friends,

I have created a tree model, when a button clicked, it will add set of nodes as row below each top node. its working fine. After adding row of nodes below the parent, I want to add another new node to left corner of each row of nodes places.

iam using below code to generate row of nodes below a parent.

function addControl() {
diagram.model.addNodeData({ key: “C_” + mainCtrlInc, category: “controlRectangle”, text: “C” + mainCtrlInc,loc: “0 141”, movable: true});
diagram.model.startTransaction(“test1”);
mainCtrlInc++;

var subObjNum = Math.pow(2,mainCtrlInc);
if(mainCtrlInc==1){
    diagram.model.addNodeData({ key: "out_1_1", category: "successRectangle", parent:"e1",text:"out_1_1", uid:"0", visible:true});
    diagram.model.addNodeData({ key: "out_1_2", category: "failureRectangle", parent:"e1",text:"out_1_2", uid:"0", visible:true});
}else{
    var curSubNo = 0;
    for(var inc1 = 1; inc1<=subObjNum/2;inc1++){
      curSubNo++;
      diagram.model.addNodeData({ key: "out_"+mainCtrlInc+"_"+curSubNo, category: "successRectangle", parent:"out_"+(mainCtrlInc-1)+"_"+inc1,text:"out_"+mainCtrlInc+"_"+curSubNo, uid:"0", visible:true});
      curSubNo++;
      diagram.model.addNodeData({ key: "out_"+mainCtrlInc+"_"+curSubNo, category: "failureRectangle", parent:"out_"+(mainCtrlInc-1)+"_"+inc1,text:"out_"+mainCtrlInc+"_"+curSubNo, uid:"0", visible:true});
    }

}
diagram.model.commitTransaction("test1");
diagram.updateAllTargetBindings();

**//Adding new node - I want to place this left corner of each row (current)**
var curLineObj = diagram.findNodeForKey("out_"+mainCtrlInc+"_1");
var p = { x: curLineObj.actualBounds.x - 300, y: curLineObj.actualBounds.y };
diagram.model.addNodeData({ key: "C_" + mainCtrlInc, category: "controlRectangle", text: "C" + mainCtrlInc, movable: true});

}

adding new node left corner of each row not working. I want to place that new node left corner of each row. same x-300, y of first node in the row

in this model, my new node going below the row instead of left side of row.

please help me friends.
Thanks and Regards,
Syed Abdul Rahim

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles