0
votes

I've got a repeat control containing five columns with values like "2.30" or "1.78" (saved as number values).

I now want to create a column total beneath the repeat control calculating the average of the column values, e.g.: (2.30 + 1.78) / 2

I know how to get the number of documents in the repeat control, but how do I get all values of the column?

getComponent("repeat1").getRowCount()
1
If repeat does not use pager (allways shows all values), simple client side javascript can do the trick - dojo.query with proper css selector and push the sum to prepared span element.Frantisek Kossuth

1 Answers

1
votes

Hi you could use the var propertie of the repeat control to access the values of the entire row and save them in the viewScope. Than you could do with them what ever you want:

  <xp:repeat id="repeat1" rows="30" value="#{view1}" var="entry"
            indexVar="indexvar">
            <xp:panel>
                <xp:text escape="true" id="computedField1">
                    <xp:this.value><![CDATA[#{javascript:var values:java.util.Vector = entry.getColumnValues();
    var array = (viewScope.add == null)? new Array():viewScope.add;
    array.push(values.elementAt(/* column */1))
    viewScope.put("add",array);
    return indexvar;
    }]]></xp:this.value>
                </xp:text>
            </xp:panel>
        </xp:repeat>

then you can display them or whatever you need:

<xp:text value="#{viewScope.add}">