在<af:table>多个column下增加合计

在<af:table>拖出来的报表,给多个列增加合计信息。

第一步:在vo的实现类里增加如下代码

import java.util.HashMap;

import java.util.Map;

import oracle.jbo.server.ViewObjectImpl;

import org.codehaus.groovy.runtime.InvokerHelper;

// ---------------------------------------------------------------------

// ---    File generated by Oracle ADF Business Components Design Time.

扫描二维码关注公众号,回复: 403931 查看本文章

// ---    Fri May 05 16:09:30 CST 2017

// ---    Custom code may be added to this class.

// ---    Warning: Do not modify method signatures of generated methods.

// ---------------------------------------------------------------------

public class VCzAssetLandView1Impl extends ViewObjectImpl {

    /**

     * This is the default constructor (do not remove).

     */

    public VCzAssetLandView1Impl() {

    }

    private class AgrFuncHelper extends HashMap {

        private String funcName;

        

        public AgrFuncHelper(String funcName) {

            super();

            this.funcName = funcName;

        }

        public Object get(Object key) {

            //Invoke private method

            //of our DefaultRowSet (sum,count,avg,min,max)

            //key is argument expression for the aggr funcion being called

            //sum("Salary")

            return InvokerHelper.invokeMethod(getDefaultRowSet(), funcName,

                                              key);

        }

    }

    public Map getSum() {

        return new AgrFuncHelper("sum");

    }

    public Map getCount() {

        return new AgrFuncHelper("count");

    }

}

第二步:在jspx页面的对应column下,增加代码

<f:facet name="footer">

                <af:panelGroupLayout id="pgl112" styleClass="AFStretchWidth"

                                   layout="horizontal" halign="right"

                                   inlineStyle="border-style:solid; border-width:1px;">

                <af:outputText value="#{bindings.VCzAssetLandView1_1.viewObject.sum['AvgValue']}"

                               inlineStyle="font-weight:bold;" id="ot392">

                  <af:convertNumber type="currency" currencySymbol=""/>

                </af:outputText>

              </af:panelGroupLayout>

            </f:facet>

整个column标签如下:

<af:column sortProperty="#{bindings.VCzAssetLandView1_1.hints.AvgValue.name}"

                     sortable="false"

                     headerText="#{bindings.VCzAssetLandView1_1.hints.AvgValue.label}"

                     id="c28">

            <af:spacer width="10" height="10" id="s1"/>

            <af:inputText value="#{row.bindings.AvgValue.inputValue}"

                          label="#{bindings.VCzAssetLandView1_1.hints.AvgValue.label}"

                          required="#{bindings.VCzAssetLandView1_1.hints.AvgValue.mandatory}"

                          columns="#{bindings.VCzAssetLandView1_1.hints.AvgValue.displayWidth}"

                          maximumLength="#{bindings.VCzAssetLandView1_1.hints.AvgValue.precision}"

                          shortDesc="#{bindings.VCzAssetLandView1_1.hints.AvgValue.tooltip}"

                          id="it46">

              <f:validator binding="#{row.bindings.AvgValue.validator}"/>

              <af:convertNumber type="currency" currencySymbol=""/>

            </af:inputText>

            <f:facet name="footer">

                <af:panelGroupLayout id="pgl112" styleClass="AFStretchWidth"

                                   layout="horizontal" halign="right"

                                   inlineStyle="border-style:solid; border-width:1px;">

                <af:outputText value="#{bindings.VCzAssetLandView1_1.viewObject.sum['AvgValue']}"

                               inlineStyle="font-weight:bold;" id="ot392">

                  <af:convertNumber type="currency" currencySymbol=""/>

                </af:outputText>

              </af:panelGroupLayout>

            </f:facet>

          </af:column>

运行结果如图:



 

猜你喜欢

转载自best0247.iteye.com/blog/2372837
AF