Xpages search between 2 dates

前端 未结 1 1289
南笙
南笙 2020-12-12 05:03

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

相关标签:
1条回答
  • 2020-12-12 05:39

    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>
    

    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>
    
    0 讨论(0)
提交回复
热议问题