![JAR search and dependency download from the Maven repository](/logo.png)
com.extjs.gxt.ui.client.widget.grid.GroupSummaryView Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gxt Show documentation
Show all versions of gxt Show documentation
Rich Internet Application Framework for GWT
/*
* Sencha GXT 2.3.0 - Sencha for GWT
* Copyright(c) 2007-2013, Sencha, Inc.
* [email protected]
*
* http://www.sencha.com/products/gxt/license/
*/
package com.extjs.gxt.ui.client.widget.grid;
import java.util.List;
import java.util.Map;
import com.extjs.gxt.ui.client.core.DomHelper;
import com.extjs.gxt.ui.client.core.El;
import com.extjs.gxt.ui.client.core.FastMap;
import com.extjs.gxt.ui.client.core.Template;
import com.extjs.gxt.ui.client.core.XDOM;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.util.Params;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.dom.client.TableSectionElement;
/**
* A GroupingView
with support for a summary row.
*/
public class GroupSummaryView extends GroupingView {
protected Template rowTpl, cellTpl;
/**
* Returns the summary node element.
*
* @param g the group element
* @return the summary node
*/
public El getSummaryNode(Element g) {
if (g != null) {
return fly(g).down(".x-grid3-summary-row");
}
return null;
}
/**
* Returns true if summaries are visible.
*
* @return true for visible
*/
public boolean isSummaryVisible() {
return !grid.el().hasStyleName("x-grid-hide-summary");
}
/**
* Toggles the summary information visibility.
*
* @param visible true for visible, false to hide
*/
public void toggleSummaries(boolean visible) {
El el = grid.el();
if (el != null) {
if (visible) {
el.removeStyleName("x-grid-hide-summary");
} else {
el.addStyleName("x-grid-hide-summary");
}
}
}
@SuppressWarnings({"unchecked", "rawtypes"})
protected Map calculate(List models, List cs) {
Map data = new FastMap();
for (int j = 0, jlen = models.size(); j < jlen; j++) {
ModelData m = models.get(j);
for (int i = 0, len = cs.size(); i < len; i++) {
ColumnData c = cs.get(i);
SummaryColumnConfig cf = (SummaryColumnConfig) cm.getColumn(i);
if (cf.getSummaryType() != null) {
data.put(c.name, cf.getSummaryType().render(data.get(c.name), m, c.name, data));
}
}
}
return data;
}
protected void doAllWidths(List ws, int tw) {
if (!enableGrouping) return;
NodeList gs = getGroups();
for (int i = 0, len = gs.getLength(); i < len; i++) {
Element s = gs.getItem(i).getChildNodes().getItem(2).cast();
El.fly(s).setWidth(tw);
if (s.getFirstChild() == null) return;
El.fly(s.getFirstChildElement()).setWidth(tw);
TableSectionElement tse = s.getFirstChildElement().cast();
NodeList cells = tse.getRows().getItem(0).getChildNodes().cast();
for (int j = 0, wlen = ws.size(); j < wlen; j++) {
El.fly(cells.getItem(j)).setWidth(ws.get(j));
}
}
}
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
protected void doGroupEnd(StringBuilder buf, GroupColumnData g, List cs, int colCount) {
Map data = calculate(g.models, cs);
buf.append("