【发布时间】:2018-01-09 14:04:01
【问题描述】:
我正在构建一个历史跟踪器,它可以继续使用非 xpage 应用程序中的遗留代码。对于 xpage 应用程序,我只需调用以下函数。这工作正常:
function AddObjectivesHistoryItem(doc, dt, action, username){
var ArrDocHistory:array = doc.getItemValueArray("History");
if(ArrDocHistory.length < 1){
// This should always return an object as it is created when an objectives
document is first
// created but do this check to be safe and create an array if for some
reason it doesnt exist
ArrDocHistory = [dt+"|"+action+"|"+username];
}else{
// append new value to the array
ArrDocHistory.push(dt+"|"+action+"|"+username);
}
return ArrDocHistory;
}
我遇到的问题是拆分和显示 3 种数据类型。我有 3 个计算字段,即重复控件内的表中的日期、用户名和状态,代码,包括下面的第一列和计算字段,这应该是每个多值的第一个管道分隔符之前的所有值。:
<table class="table table-hover">
<thead>
<tr>
<th>Date</th>
<th>Action</th>
<th>Username</th>
</tr>
</thead>
</table>
<table class="table table-hover">
<xp:repeat value="#{document1.History}" var="row">
<tbody>
<tr>
<td>
<xp:text escape="true" id="computedField1">
<xp:this.value><![CDATA[#{javascript:var ArrDocHistory:array = document1.getItemValueArray("History");
print ("LEN: " + ArrDocHistory.length);
var test:array = new Array();
for (i=0; i<ArrDocHistory.length; i++){
var split = ArrDocHistory[i].split("|");
test.push(split[0]);
//return split[i]
}
return test}]]></xp:this.value>
</xp:text></td>
但是,这显示的是所有值,在一行中,用逗号分隔。例如,“value1,value2,value3”正如我所料,需要,并且似乎无法让每个值在新行中单独显示。例如:
值1
值2
值3
我知道我在做一些愚蠢的事情,但目前正遭受隧道视力的困扰,因此非常感谢任何指点。
【问题讨论】:
-
看起来您在重复中循环历史字段。跳过它并在重复时使用行变量
-
干杯托马斯..
标签: xpages xpages-ssjs