Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

CubeGrid advanced - sums

$
0
0
evaluating SmartGWT 4.0 power

I was under the assumption that the "sums" are generated out of the existing values. but I guess I was wrong ?

regarding the code please refer to http://forums.smartclient.com/showthread.php?t=27461

additionally I have the following method

Code:

    public static Facet[] getFacets(FacetObjs facets) {
        List<Facet> l = new ArrayList<Facet>();
       
        for (FacetObj fo : facets.getFacets()) {
            Facet f = new Facet(fo.getId(), fo.getTitle());
            if (fo.getChildren().isEmpty() == false) {
                f.setIsTree(true);
            }
            if (fo.getChildren().isEmpty() == false) {
                FacetValue sum = null;
                if (fo.isSum()) {
                    sum = new FacetValue("sum", "all " + fo.getId(), fo.getId());
                }
                List<FacetValue> vals = new ArrayList<FacetValue>();
                for (String s : fo.getChildren()) {
                    FacetValue fv;
                    if (sum == null) {
                        fv = new FacetValue(s, s, fo.getId());
                    } else {
                        fv = new FacetValue(s, s, "sum");
                    }
                    vals.add(fv);
                }
                if (sum == null) {
                    f.setValues(vals.toArray(new FacetValue[vals.size()]));
                } else {
                    FacetValue[] valsa = new FacetValue[vals.size() + 1];
                    valsa[0] = sum;
                    for (int cnt = 0; cnt < vals.size(); cnt++) {
                        valsa[cnt+1] = vals.get(cnt);
                    }
                    f.setValues(valsa);
                }
            }
           
            l.add(f);
        }
        return l.toArray(new Facet[l.size()]);
    }

in order to generate my facets. The code for the view is the same as in the showcase for the advanced grid, with
the following adaptations:

Code:

        advancedCube.setFacets(Facets.getFacets());    advancedCube.setFacets(Facets.getFacets(CubeData.getFacets()));        advancedCube.setData(CubeData.getData());      advancedCube.setValueProperty(CubeItem.value);advancedCube.setCellIdProperty(CubeItem.kid);
advancedCube.setRowFacets("ips", "urls"); 
advancedCube.setColumnFacets("days");

the grid shows with the data I provide, but not the sums

What do I have to do in order to get the sums displayed as well?

Viewing all articles
Browse latest Browse all 4756

Trending Articles