Xpages get a handle on next rowData or Doc in a repeat

☆樱花仙子☆ 提交于 2020-01-02 10:07:58

问题


In my repeat control I want to be able to get a handle on data in the next row in order to modify what data is displayed in my current row (I have move up and down actions, and I don't want to display them if the move is not possible).

It seems I should be able to do this. Probably I cannot from within in the repeat itself, as when it is writing the repeat it will not know the data for the next repeat. But shouldn't there be a fairly easy way to get the next document?

Here is a reduced version of my repeat control:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

<xp:repeat
                id="repeat1"
                var="rowData"
                indexVar="repeatIndex"
                value="#{view1}"><xp:this.facets>
                    <xp:text
                        disableTheme="true"
                        xp:key="header"
                        escape="false"
                    >
                        <xp:this.value><![CDATA[<table class='lotusTable repeatRowColors' border='0' cellspacing='0' cellpadding='0' width='800px'>
<tr class ='lotusFirst lotusSort scope='col'>
<th class ='loutsFirstCell'></th>
<th class ='loutsFirstCell'>Category</th>
<th class ='lotusCenter'>Move</th>
<th>Task</th>
</tr>
</thead>]]></xp:this.value>

                    </xp:text>
                    <xp:text
                        disableTheme="true"
                        xp:key="footer"
                        escape="false"
                    >
                        <xp:this.value><![CDATA[</table>]]></xp:this.value>

                    </xp:text>
                </xp:this.facets>
                <xp:this.rows><![CDATA[#{javascript:var rows:Integer = viewScope.get("rows");
if (rows == null)
{return 5}
else
{return rows}}]]></xp:this.rows>
                <xp:tr id="rowDataContainer">

                    <xp:td
                        style="width:55px;min-width:55px;max-width: 55px;">
                        <xp:text
                            escape="true"
                            id="computedField2">
                            <xp:this.value><![CDATA[#{javascript:rowData.getColumnValue("category");}]]>
                            </xp:this.value>
                        </xp:text>
                    </xp:td>

                </xp:tr>
            </xp:repeat>
</xp:view>

回答1:


You can get view's next row within the repeat with

var nextRow = view1.getAllEntries().getNthEntry(repeatIndex + 2);

"view1" is the xp:dominoView assigned to repeat control and "repeatIndex" is the indexVar of xp:repeat.

You can get next row document's UniqueID then with

nextRow ? nextRow.getUniversalID() : ""

and the e.g. Form field with

nextRow ? nextRow.getDocument().getItemValueString("Form") : ""

Accordingly, you get the previous row with

var prevRow = view1.getAllEntries().getNthEntry(repeatIndex);


来源:https://stackoverflow.com/questions/29905981/xpages-get-a-handle-on-next-rowdata-or-doc-in-a-repeat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!