I'm using ag-grid to display JSON data. If values are held in nested objects I have to use a valueGetter (grid API) to map to the value. 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. 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.
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.
New valueGetter method :
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.