PowerBi Api:如何使用上下文菜单命令将单元格内容复制到剪贴板

PowerBi Api: how to copy cell contents to clipboard using a context menu command

我正在尝试将报告的单元格内容复制到我的 Microsoft PowerBI 应用程序的剪贴板中。

在我的配置中我有这个:

    settings: {
        filterPaneEnabled: true,
        navContentPaneEnabled: true,
        extensions: [
            {
                command: {
                    name: "CopyToClipBoard",
                    title: "Copy to Clipboard",
                    extend:
                    {
                        visualContextMenu: {
                            title: "Copy"
                        }
                    }
                }
            }
        ]
    }

这会弹出一个右键单击菜单,我在其中看到 复制 作为我的新选项。

然后我创建了收集数据的方法:

report.on("commandTriggered", function (command) {
    console.log(command);
    var details = command.detail;
    if (details.command === "CopyToClipBoard") {
 //I thought the selection was in the first DataPoint, first Identity. It's not.
        var dpoints = details.dataPoints[0].identity[0].equals;
        CopyData(dpoints);
    }
});



function CopyData(dpoints) {
    //Get the selected text and append the extra info
    var newdiv = document.createElement('div');
    var selection = window.getSelection();


    //hide the newly created container
    newdiv.style.position = 'absolute';
    newdiv.style.left = '-99999px';

    //insert the container, fill it with the extended text, and define the new selection
    document.body.appendChild(newdiv);
    newdiv.innerHTML = dpoints;
    selection.selectAllChildren(newdiv);
    document.execCommand("copy");

    window.setTimeout(function () {
        document.body.removeChild(newdiv);
    }, 100);
}

问题是该命令不包含单元格中的任何元素。它仅包含包含单元格位置或标识的数据 point/Identity。

我怎样才能得到单元格文本?

看起来截至目前收集值仍在进行中.... https://github.com/Microsoft/PowerBI-JavaScript/wiki/Handling-Events