Xpages在2个日期之间搜索

Flo*_*Pop 1 search xpages difference

我有一些数据的视图,以及一个包含每个文档的创建日期的列.我想创建一个包含3个输入字段的搜索功能:Name,StartDate,EndDate.搜索结果应该是所有具有相同名称且在2个日期内的文档.

谁能帮我?

谢谢

Knu*_*ann 5

使用searchDominoView数据源的属性.它对视图中的所有文档进行全文搜索.创建一个搜索字符串

[Name]="Meier" AND [_creationDate]>=12-01-2013 AND [_creationDate]<=30-08-2014
Run Code Online (Sandbox Code Playgroud)

您的数据源代码如下所示:

    <xp:this.data>
        <xp:dominoView
            var="view1"
            viewName="YourView">
            <xp:this.search><![CDATA[#{javascript:
            var search = "";
            var formatter = new java.text.SimpleDateFormat("dd-MM-yyyy");
            if (viewScope.Name) {
                search += ' AND [Name]="' + viewScope.Name + '*"';
            }
            if (viewScope.StartDate) {
                search += ' AND [_creationDate]>=' + formatter.format(viewScope.StartDate);
            }
            if (viewScope.EndDate) {
                search += ' AND [_creationDate]<=' + formatter.format(viewScope.EndDate);
            }
            return search.substring(5);}]]></xp:this.search>
        </xp:dominoView>
    </xp:this.data>
Run Code Online (Sandbox Code Playgroud)

此代码假定有其价值必将为可编辑的搜索字段viewScope.Name,viewScope.StartDate以及viewScope.EndDate如

<xp:inputText
    id="inputText1"
    value="#{viewScope.Name}">
</xp:inputText>

<xp:inputText
    id="inputText2"
    value="#{viewScope.StartDate}">
    <xp:this.converter>
        <xp:convertDateTime
            type="date"
            dateStyle="short">
        </xp:convertDateTime>
    </xp:this.converter>
    <xp:dateTimeHelper></xp:dateTimeHelper>
</xp:inputText>
Run Code Online (Sandbox Code Playgroud)