Search code examples
xpagesrepeatview-scope

Xpages viewScope to sort a repeat control column


I am trying to click a link and sort a view by a column in a repeat using viewScope with a full SSJS refresh (also tried partial refresh on the the repeat control, on the table within, and on the panel surrounding the whole thing). When I click it, it is releaoading the repeat control and clearing the data. What am I doing wrong? Inevitably, I want to use this in the header of the repeat panels header facet.

<xp:link escape="true" text="Sort by DoorName" id="link1">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="complete">
            <xp:this.action><![CDATA[#{javascript:viewScope.put("col","DoorName")}]]></xp:this.action>
        </xp:eventHandler></xp:link>

    <xp:panel style="width:99.0%">      
        <xp:repeat id="repeat2" rows="500" var="rowdoc2"
            repeatControls="true" value="#{view2}">
            <xp:this.facets>
                <xp:text disableTheme="true" xp:key="header"
                    escape="false">
                    <xp:this.value>
                        <![CDATA[<table class="simple">
                        <th style="width:200px">TITLE</th>
                        <th style="width:200px">2nd HEADER</th></table>]]>
                    </xp:this.value>
                </xp:text>
            </xp:this.facets>
            <xp:table style="width:100.0%" styleClass="simple">
                <xp:tr>
                    <xp:td style="width:200px">
                        <xp:text escape="true" id="computedField2"
                            value="#{rowdoc2.DoorName}">
                        </xp:text>
                    </xp:td>

                    <xp:td style="width:200px">
                        <xp:text escape="true" id="computedField1"
                            value="#{rowdoc2.DoorDesc}">
                        </xp:text></xp:td>
                </xp:tr>
            </xp:table>
        </xp:repeat>

    </xp:panel>

EDIT>>>>>I put the "col" the XPAGE data's Sort column computed value. Maybe that's the part that's not correct.

    <xp:this.data>      
    <xp:dominoView var="view2" viewName="Doors">
        <xp:this.sortColumn><![CDATA[#{javascript:viewScope.get("col")}]]></xp:this.sortColumn>
    </xp:dominoView>
</xp:this.data>

Solution

  • Just delete repeat's property repeatControls="true" and it will work as expected.

    This property causes the repeat components to render at page load only. You can find a good explanation here