XPages dataTable 控件,计算可见

XPages dataTable control, compute visible

我正在尝试学习如何在数据表上执行计算可见 属性 以在启用或禁用状态时隐藏字段/行。

下面的代码是我用过的,但一直出错

var userName=rowData.getColumnValue("userName")
var status:NotesView = database.getView("(UserProfile)");
var doc:NotesDocument = status.getDocumentByKey(userName);
var active = doc.getItemValueString("Status")
if(active == "Enabled") {
    return true
}else{
return false
}

将您的代码放入 try-catch-block,因为您希望该部分仅在用户在视图“(UserProfile)”中并且具有特定状态时可见:

try {
    var userName=rowData.getColumnValue("userName")
    var status:NotesView = database.getView("(UserProfile)");
    var doc:NotesDocument = status.getDocumentByKey(userName);
    var active = doc.getItemValueString("Status")
    if(active == "Enabled") {
        return true;
    } else {
        return false;
    }
} catch (e) {
    return false;
}

这是页面加载失败还是部分刷新失败?如果是后者,您可能会遇到我在这里提到的问题 http://www.intec.co.uk/dataviews-and-nested-repeats/。部分刷新是服务器端的多个阶段,在此期间检索页面的服务器端映射、应用来自浏览器的值以及重新计算数据 Table 的内容。在早期阶段,变量 rowData 将为空,这意味着 doc 也将为空。

使用像 XPages OpenLog Logger 这样的日志记录机制将捕获堆栈跟踪,其中将包括它失败的阶段。

使用 view.isRenderingPhase() 仅 运行 呈现响应阶段(将 HTML 写回浏览器的阶段)中的代码。它将避免特定阶段的问题并优化性能。如果呈现 属性,那是您需要计算 ;-)

中的值的唯一阶段