在2个日期之间搜索Xpages [英] Xpages search between 2 dates

查看:74
本文介绍了在2个日期之间搜索Xpages的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一些数据的视图,以及一个包含每个文档的创建日期的列。
我想使用3个输入字段进行搜索:
Name,StartDate,EndDate。
搜索的结果应该是两个日期内具有相同名称的所有文档。

I have a view with some data, and a column with the creation date of each document. I want to make a search feature with 3 input fields: Name, StartDate, EndDate. The result of the search should be all the documents with the same name and within the 2 dates.

有人可以帮助我吗?

谢谢

推荐答案

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

Use the search property of DominoView data source. It does a full text search on all documents in view. Create a search string like

[Name]="Meier" AND [_creationDate]>=12-01-2013 AND [_creationDate]<=30-08-2014

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

Your data source code would look like this:

    <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>

此代码假定存在一些可编辑的搜索字段,其值绑定到 viewScope .Name viewScope.StartDate viewScope.EndDate 例如

This code assumes that there are editable search fields which value is bound to viewScope.Name, viewScope.StartDate and viewScope.EndDate e.g.

<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>

这篇关于在2个日期之间搜索Xpages的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆