xPages DataView和Repeat控件

时间:2014-03-11 15:00:31

标签: xpages xpages-extlib xpages-ssjs

我在数据库中有两种形式:fmKopf(head)和fmPos(position)。我有一个DataView,我用来向我展示所有的fmKopf文件 - 这非常有效。记录的var名称是" rowHandle"。我已经在dataView的details部分添加了一个重复控件,我想在其中显示fmKopf的fmPos文档。 repeat var name是" rowData"。 repleat控件的值是:

var posView:NotesView = database.getView("xpPositions");
if (rowHandle.isDocument()) {
    var key = rowHandle.getColumnValue("searchKey"); 
    var vecLieferscheine:NotesViewEntryCollection = posView.getAllDocumentsByKey(key);
    return vecLieferscheine;
} else {
    return null;
}

然后我在重复控件中添加了一个计算字段,但是在我的生命中我不知道用什么来显示fmPos文档中的相应数据。如果我只显示rowData,我会得到Notes文档的UID - 这是有道理的,因为我们正在返回一个NotesViewEntryCollection。然后我尝试了以下代码:

var doc:NotesDocument = database.getDocumentByUNID(rowData);
return doc.getItemValue("DLNTLP");

从fmPos文档显示字段DLNTLP - 这不起作用,因为rowData是NotesViewEntryCollection而不是单个值。这会导致页面崩溃。

我需要什么代码才能让计算字段显示基础文档中的值?

感谢您提供任何帮助。 熊属

1 个答案:

答案 0 :(得分:0)

抱歉,我不得不多次编辑答案,不知道为什么,但stackoverflow让我失望。

  1. getAllDocumentsByKey(key)不会返回一个NotesViewEntryCollection,它会返回一个NotesDocumentCollection,它不会真正起作用,只是跳过.getDocument();

  2. 因此,在xp:repeat已有NotesDocuments,您可以使用它们,而不需要使用database.getDocumentByUNID()从数据库中获取文档。

  3. 您可以使用以下代码通过重复内部的数据源访问您的文档(与database.getDocumentByUNID()或多或少相同):

    <xp:repeat
        id="repeat1" rows="30"
        value="YourCode" var="detailDoc">
            <xp:panel 
               <xp:this.data>
                    <xp:dominoDocument var="document1"
                        action="openDocument"
                        documentId="#{javascript:detailDoc.getUniversalID()}">
                    </xp:dominoDocument>
            </xp:this.data>
        </xp:panel>
    </xp:repeat>
    

    或direkt访问您的收藏集中的每个文档:

    <xp:repeat
        id="repeat1" rows="30"
        value="YourCode" var="detailDoc">
            <xp:panel 
              <xp:text>
                <xp:this.value><![CDATA[#{javascript://
                         var  doc:NotesDocument = detailDoc;
                         return doc.getItemValueString('DLNTLP');
                 </xp:this.value>
             </xp:text>
        </xp:panel>
    </xp:repeat>
    

    如果您只需要文档中的一个或两个字段,我将使用secound方法,如果您还想操作这些字段,则第一个非常有用,因为您可以使用文档数据源及其所有功能。如果要显示附件,第一个示例也很有用。