Hi,
I want to edit text on double click of text block its working if text block is not empty but its not working if its empty.
- Edit functionality on double click
- How we can add Text Box not Text Block as Text Block is multiline text box I do not need multiline text box. I need only single line text box.
Here is the code which I am using to make editable,
myDiagram.nodeTemplateMap.add(“UnitMember”,
GO(go.Node, “Auto”, {
mouseDrop: fnNodeDrop,
mouseHold: fnNodeDrag,
movable: false,
//fromLinkable: true,
//toLinkable: true,
mouseEnter: function (e, node) {
nodeMouseIn(node, node);
model.startTransaction("modified ");
var x = node.findMainElement();
x.stroke = "#ff0000";
model.commitTransaction("modified ");
//console.log(e, node);
},
mouseLeave: function (e, node) {
nodeMouseOut(node);
////;
model.startTransaction("modified ");
var x = node.findMainElement();
x.stroke = "#000";
model.commitTransaction("modified ");
//console.log(e, node);
}
},
//new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
GO(go.Shape, "Rectangle", {
width: OrgChartConfig.GroupWidth,
// height: OrgChartConfig.UnitMemberHeight,
strokeWidth: 1,
stroke: "#555",
fromLinkable: false,
toLinkable: false
},
// new go.Binding("width", "width", function (w) { return scaleWidth(w); }),
new go.Binding("fill", "color")),
GO(go.Panel, "Table", {
alignment: go.Spot.Left,
margin: 2
},
GO(go.TextBlock, {
row: 0,
column: 0,
editable: true,
alignment: go.Spot.Left,
width: OrgChartConfig.GroupWidth,
wrap: go.TextBlock.WrapFit,
columnSpan: 5,
margin: 2,
}, {
font: "normal 14pt sans-serif"
},
new go.Binding("text", "Name").makeTwoWay()),
GO(go.TextBlock, {
row: 1,
column: 0,
editable: true,
alignment: go.Spot.Left,
width: OrgChartConfig.GroupWidth,
wrap: go.TextBlock.WrapFit,
margin: 1,
columnSpan: 5,
}, {
font: "normal 14pt sans-serif",
},
new go.Binding("text", "Title").makeTwoWay()),
GO(go.Picture, {
row: 2,
column: 0,
source: "../../images/OrgChartGojs/call6.png",
width: OrgChartConfig.ActionIconDimension,
height: OrgChartConfig.ActionIconDimension,
alignment: go.Spot.Left,
margin: 1,
name: "PhoneIcon",
visible: false,
}),
GO(go.TextBlock, {
row: 2,
column: 1,
editable: true,
width: parseInt(OrgChartConfig.GroupWidth) - 85,
wrap: go.TextBlock.WrapFit,
margin: 1,
},
{
font: "normal 14pt sans-serif"
},
new go.Binding("text", "Contact").makeTwoWay()
),
GO(go.Panel, "Horizontal",
{
row: 2,
column: 2,
name: "AddIcon",
alignment: go.Spot.Right,
width: OrgChartConfig.ActionIconDimension,
height: OrgChartConfig.ActionIconDimension,
visible: false,
},
GO(go.Picture, {
source: "../../images/OrgChartGojs/add.png",
width: OrgChartConfig.ActionIconDimension,
height: OrgChartConfig.ActionIconDimension,
cursor: "pointer",
click: AddChildIconClick,
alignment: go.Spot.Right,
})
),
GO(go.Panel, "Horizontal",
{
row: 2,
column: 3,
name: "EditIcon",
defaultAlignment: go.Spot.Right,
width: OrgChartConfig.ActionIconDimension,
height: OrgChartConfig.ActionIconDimension,
visible: false,
},
GO(go.Picture, {
//margin: new go.Margin(0, 10),
source: "../../images/OrgChartGojs/edit.png",
width: OrgChartConfig.ActionIconDimension,
height: OrgChartConfig.ActionIconDimension,
cursor: "pointer",
click: editIconClick,
alignment: go.Spot.Right,
})
),
GO(go.Panel, "Horizontal",
{
row: 2,
column: 4,
name: "DeleteIcon",
defaultAlignment: go.Spot.Right,
width: OrgChartConfig.ActionIconDimension,
height: OrgChartConfig.ActionIconDimension,
visible: false
},
GO(go.Picture, {
source: "../../images/OrgChartGojs/delete.png",
width: OrgChartConfig.ActionIconDimension,
height: OrgChartConfig.ActionIconDimension,
cursor: "pointer",
click: deleteIconClick,
alignment: go.Spot.Right,
})
)
// using a function in the Binding allows the value to
// change when Diagram.updateAllTargetBindings is called
//new go.Binding("location", "loc",
// function (l) { return new go.Point(scaleWidth(l.x), l.y); })
),
GO("TreeExpanderButton", {
alignment: go.Spot.Bottom,
alignmentFocus: go.Spot.Top
}
)
//,
//GO("TreeExpanderButton", {
// alignment: go.Spot.Bottom,
// alignmentFocus: go.Spot.Top
//}
//)
)
);
Please see attached image.