如何从 link 格式化程序 url 回调 return 而不进行 hyperlink

How to return from link formatter url callback without making a hyperlink

我正在使用格式化程序:"link" url 回调为我的 Tabulator table

中的特定列生成 hyperlink
tabulatorTable.addColumn({
    title: "Value",
    field: "JSONDoc.Path.To.Property",
    formatter: "link",
    formatterParams: {
        url: getHyperLink,
        target: "_blank"
    }
});

然后在我的回调函数中:

function getHyperLink(cellComp) {
    var cellData = cellComp.getData();

    var propValFromJSONSource = cellData.SomeProperty;

    if( propValFromJSONSource != 0) {
        return "http://hostname/report/showLog.php?prop=" + propValFromJSONSource;
    }
    else {
        // If here, I can't generate a valid link, so I want to not have a hyperlink and just show the data
        return ???;
    }
}

我可以在格式化程序 return 的 else 语句中做些什么来指示 Tabulator 不创建 hyperlink?

我试过:

return "";  // This makes the hyperlink go to "<currentURL>"
return null; // This generates a relative hyperlink to "<currentURL>/null"
return undefined; // This generates a relative hyperlink to "<currentURL>/undefined"

我怀疑我可能无法使用 link 格式化程序,需要切换到 returns 的自定义格式化程序回调“

我也有无法左键单击 hyperlink 的问题(即使它在状态栏中正确显示);我只能单击中心或单击鼠标右键并选择 "Open in new tab"。我不确定这是 Tabulator 中的错误,还是 Chrome 出于某种原因不理解它,但这应该是另一个 SO 问题...

目前,我建议使用自定义格式化程序:

tabulatorTable.addColumn({
    title: "Value",
    field: "JSONDoc.Path.To.Property",
    formatter: getHyperLink,
});

然后让回调 return 超链接的 html 代码或只是文本:

function getHyperLink(cellComp, formatterParams, onRendered) {
    var cellData = cellComp.getData();
    var cellValue = cellComp.getValue();

    var propValFromJSONSource = cellData.SomeProperty;

    if( propValFromJSONSource != 0) {
        var hrefString = "http://hostname/report/showLog.php?prop=" + propValFromJSONSource;
        return "<a href='" + hrefString + "' target='_blank'>" + cellValue + "</a>";
    }
    else {
        return cellValue;
    }
}