简体   繁体   English

使用javascript .link()方法打开弹出窗口

[英]Open popup with javascript .link() method

I'm using ag-grid to display JSON data. 我正在使用ag-grid显示JSON数据。 If values are held in nested objects I have to use a valueGetter (grid API) to map to the value. 如果值保留在嵌套对象中,则必须使用valueGetter(网格API)来映射到该值。 The value getter returns a value per row and the grid assigns the correct value to the correct row. 值获取器每行返回一个值,网格将正确的值分配给正确的行。 Problem is I need each value to be a hyperlink, which opens a popup. 问题是我需要每个值都是一个超链接,这将打开一个弹出窗口。 I have an openPopup() method which uses window.open. 我有一个使用window.open的openPopup()方法。 However AFAIK I'm forced to use javascripts .link() method, which only takes a URL string so I can't figure out how to open the link in a new window. 但是AFAIK我被迫使用javascripts .link()方法,该方法仅采用URL字符串,因此我不知道如何在新窗口中打开链接。

Value getter : 价值获取者:

function isinValueGetterBox(params) {
    if (params.node.group) { return null; }
    var isinValueBox = "";

    for (var i = 0; i < params.data.security.identifiers.length; i++) {
        if (params.data.security.identifiers[i].type === "isin") {
            isinValueBox = params.data.security.identifiers[i].value;
        }
    }
    return isinValueBox.link("views/Popup1.html");
}

popup method : 弹出方法:

popup1 = function () {
    var popup1 = window.open("views/Popup1.html", "_blank",
                        "height = 400, width = 700");
}

Found out it's possible to utilize HTML from within javascript when creating a string, so I simply attached an <a> tag with an onclick to call my window.open method. 发现在创建字符串时可以在javascript中利用HTML,因此我只需在onclick上附加<a>标记即可调用我的window.open方法。

New valueGetter method : 新的valueGetter方法:

 function isinValueGetterBox(params) {
    if (params.node.group) { return null; }
    var isinValueBox = "";

    for (var i = 0; i < params.data.security.identifiers.length; i++) {
        if (params.data.security.identifiers[i].type === "isin") {
            isinValueBox = ('<a href = "#" onclick = popup1()>' + params.data.security.identifiers[i].value + '</a>');
        }
    }
    return isinValueBox;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM