【问题标题】:how to get selected cell value in Iframe in mxGraph?如何在 mxGraph 的 Iframe 中获取选定的单元格值?
【发布时间】:2012-12-24 10:00:01
【问题描述】:

我们如何在框架中获取选定的单元格值?我通过单击链接调用 iframe。在 Iframe 中,我想获取所选单元格的属性值。

 <script>
        function main(container) {
            if (!mxClient.isBrowserSupported()) {
                mxUtils.error('Browser is not supported!', 200, false);
            }
            else {
                var graph = new mxGraph(container);
                var cell = graph.getSelectionCell();
            }
  </script>

<body onload="main(window.parent.document.getElementById('graphContainer'))">
    <form id="form1" runat="server">

    </form>
</body>

【问题讨论】:

  • iFrame 是否在同一个域中?你能告诉我们你的 HTML 设置吗?也许是 jsfiddle.net 的例子?
  • 是的,Iframe 在同一个域中。

标签: javascript html iframe mxgraph jgraph


【解决方案1】:

如果你使用的是按钮之类的东西

您可以从 evt 中获取您正在查找的大部分信息

例如:

    graph.addListener(mxEvent.DOUBLE_CLICK, function(sender, evt)
    {
        var cell = evt.getProperty('cell');
        if (cell != null && cell.parent != main_class) {
                main_class = cell.edges[0].value.slice(14, cell.edges[0].value.indexOf('-') );

等等……

您显然可以使用 Firefox 中的调试器来确定您要查找的属性在分类中的位置

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-04
    • 1970-01-01
    • 1970-01-01
    • 2011-10-23
    • 1970-01-01
    • 1970-01-01
    • 2013-08-09
    • 2018-03-10
    相关资源
    最近更新 更多