2017-10-07 54 views
0

当我双击节点文本编辑是去哪里,而不是节点。下面是代码,我不知道发生了什么。我使用AJAX从服务器端获取mxGraph XML。当我双击节点文本编辑是去哪里

编辑源代码按注释

// Creates the div for the graph 
mxEvent.disableContextMenu(container); 
document.body.appendChild(container); 
var xmlDocument = mxUtils.parseXml(xml); 
var decoder = new mxCodec(xmlDocument); 
var node = xmlDocument.documentElement; 
container.innerHTML = ''; 
graph = new mxGraph(container); 
    graph.cellEditor.init(); 
     graph.cellEditor.textarea.style.position='absolute'; 
graph.setHtmlLabels(true); 
graph.setPanning(true); 
graph.setTooltips(true); 
graph.setConnectable(true); 
// Changes the default style for edges "in-place" 
var style = graph.getStylesheet().getDefaultEdgeStyle(); 

style[mxConstants.STYLE_ROUNDED] = true; 
style[mxConstants.STYLE_EDGE] = mxEdgeStyle.ElbowConnector; 
decoder.decode(node, graph.getModel()); 

var layout = new mxHierarchicalLayout(graph, mxConstants.DIRECTION_WEST); 
var parent = graph.getDefaultParent(); 
layout.execute(parent); 
+0

任何人都可以帮忙吗? – Kumar

回答

0

添加初始化过程中下面的代码段帮我

graph.cellEditor.init(); 
graph.cellEditor.textarea.style.position='absolute'; 
+0

首先编辑它正在工作。下次再不行。请参阅我上面编辑的源代码。 – Kumar

+0

请帮忙。这是一个奇妙的工具。 – Kumar

+0

只需添加这个帮助我。图形是全球性的,我在初始化过程中已经完成了这个 – ksholla20