Xpages 在 2 个日期之间搜索 [英] Xpages search between 2 dates
问题描述
我有一个包含一些数据的视图,以及一个包含每个文档创建日期的列.我想用 3 个输入字段创建一个搜索功能:名称、开始日期、结束日期.搜索结果应该是2个日期内的所有同名文档.
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 数据源的 search
属性.它对视图中的所有文档进行全文搜索.创建一个像
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>
这篇关于Xpages 在 2 个日期之间搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!