简体   繁体   English

Xpages-在重复控件中显示过滤的文档集合

[英]Xpages - Display filtered Document Collection in a repeat control

I have the following code which I have in the Bind data part of a repeat control. 我在重复控件的“绑定数据”部分中具有以下代码。 I have called the Collection Name 'docs'. 我称集合名称为“ docs”。 I cannot seem to make any values appear in the view control. 我似乎无法使任何值出现在视图控件中。 Computed Field - docs.getItemValue("Status"). 计算字段-docs.getItemValue(“ Status”)。 Any ideas where I'm going wrong? 有什么想法我要去哪里吗?

var v:NotesView = database.getView("xpageReports");
viewScope.status=""

// Created After
var after = viewScope.crafter
if(after==null)after = @Date(2000, 1, 1, 0, 0, 0);  

// Created Before
var before = viewScope.crbefore 
if(before==null) before = @Date( @Tomorrow() );

// Build Date Range
var dr = session.createDateRange(after, before);

// Status
var status = viewScope.crstatus;
if(status =="-select-") status =""
// Department
var department = viewScope.crdepartment;
if(department =="-select-") department=""

// Unit
var unit = viewScope.crunit;
if(unit ="-select-") unit=""

var dc:NotesDocumentCollection = v.getAllDocumentsByKey(dr);
if (dc.getCount() == 0) {
    viewScope.status = "0";
    return;
}

var count = 0
var doc:NotesDocument = dc.getFirstDocument();
while (doc != null) {
    var tmpdoc = dc.getNextDocument();
    var remove = 0

    @If(status!="",@If(doc.getItemValueString("Status")!=status,remove = remove + 1,""),"")
    @If(department!="",@If(doc.getItemValueString("Department")!=department,remove = remove + 1,""),"")
    @If(unit!="",@If(doc.getItemValueString("Unit")!=unit,remove = remove + 1,""),"")
    if(remove!=0) dc.deleteDocument(doc)

    doc.recycle();


    doc = tmpdoc;

    }

return dc

I changed the code to return the noteIDs of the documents and placed this inside the Bind Data section of the repeat control, and set the Collection Name to docs 我更改了代码以返回文档的noteID,并将其放置在重复控件的Bind Data部分中,并将Collection Name设置为docs

var v:NotesView = database.getView("xpageReports");
var docIDs = ""

// Created After
var after = viewScope.crafter
if(after==null)after = @Date(2000, 1, 1, 0, 0, 0);  

// Created Before
var before = viewScope.crbefore 
if(before==null) before = @Date( @Tomorrow() );

// Build Date Range
var dr = session.createDateRange(after, before);

// Status
var status = viewScope.crstatus;
if(status =="-select-") status =""
// Department
var department = viewScope.crdepartment;
if(department =="-select-") department=""

// Unit
var unit = viewScope.crunit;
if(unit =="-select-") unit=""

var dc:NotesDocumentCollection = v.getAllDocumentsByKey(dr);
if (dc.getCount() == 0) {
    return;
}

var count = 0
var doc:NotesDocument = dc.getFirstDocument();
while (doc != null) {
    var tmpdoc = dc.getNextDocument();
    var remove = 0

    @If(status!="",@If(doc.getItemValueString("Status")!=status,remove = remove + 1,""),"")
    @If(department!="",@If(doc.getItemValueString("Department")!=department,remove = remove + 1,""),"")
    @If(unit!="",@If(doc.getItemValueString("Unit")!=unit,remove = remove + 1,""),"")
    if(remove==0) docIDs = docIDs = docIDs + doc.getNoteID()+";"

    doc.recycle();
    doc = tmpdoc;

}
return @Explode(docIDs,";")

Then I placed a panel inside the repeat control, set the data source to the form of the documents and set the Document ID field to computed and entered docs . 然后,我在重复控件中放置了一个面板,将数据源设置为文档的形式,并将“文档ID”字段设置为“计算的”和“输入的docs” Now any computed fields I put inside the panel can be bound to the form field 现在,我放入面板中的所有计算字段都可以绑定到表单字段

As far as I understand your question you want to display subset of documents in a view in the repeat control - your filtering should be done by date range. 据我了解您的问题,您想在重复控件的视图中显示文档的子集-您应该按日期范围进行过滤。 I accomplished something similar by using the following logic: 我通过使用以下逻辑完成了类似的工作:

  1. The data source of my custom control / xpage was a view (in your case the view "xpageReports") with data source name = "view1". 我的自定义控件/ xpage的数据源是一个数据源名称为“ view1”的视图(在您的情况下为“ xpageReports”视图)。
  2. In the data source properties you have three options to narrow down your document set: "filter by category name", "filter by column value" and "search in view results". 在数据源属性中,您可以使用三个选项来缩小文档集的范围:“按类别名称过滤”,“按列值过滤”和“在视图结果中搜索”。 In my case I used "search in view results" (in a database with fulltext index). 就我而言,我使用“在视图结果中搜索”(在具有全文索引的数据库中)。 So you can use a JavaScript to create a query like this: 因此,您可以使用JavaScript创建如下查询:

'[dateAfter]>=01.01.2000 AND [dateAfter]<=31.12.2012';

  1. In the repeat you can set the source to "view1" 在重复中,您可以将源设置为“ view1”

  2. collection name can be set to "mydoc" 集合名称可以设置为“ mydoc”

  3. A column value in a computed field within the repeat can be accessed by using the code 可以使用以下代码访问重复中计算字段中的列值

mydoc.getColumnValue("PROGRAMMATICCOLUMNNAME");

I hope that is a hint into the right direction. 我希望这是正确方向的提示。 As far as I understand that should fit your requirements. 据我了解,这符合您的要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM