PDA

View Full Version : [FIXED][1.1] Summary Grid failed with setShowGroupedColumn(false)



mike07
18 Sep 2008, 7:47 AM
The test file:



public class Test implements EntryPoint {
private class Plant extends BaseModelData {
public Plant(String name, String light, double price, boolean indoor) {
setName(name);
setLight(light);
setPrice(price);
setIndoor(indoor);
}



public boolean isIndoor() {
return (Boolean)get("indoor");
}


public void setIndoor(boolean indoor) {
set("indoor", indoor);
}


public String getLight() {
return get("light");
}


public void setLight(String light) {
set("light", light);
}


public String getName() {
return get("name");
}


public void setName(String name) {
set("name", name);
}


public double getPrice() {
return (Double)get("price");
}


public void setPrice(double price) {
set("price", price);
}


}



private Grid getGrid() {
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();


SummaryColumnConfig column = new SummaryColumnConfig ();
column.setId("name");
column.setHeader("Common Name");
column.setWidth(220);


TextField text = new TextField();
text.setAllowBlank(false);
text.setAutoValidate(true);
configs.add(column);


column = new SummaryColumnConfig ();
column.setId("light");
column.setHeader("Light");
column.setWidth(130);
configs.add(column);


SummaryColumnConfig summaryColumn = new SummaryColumnConfig("price", "Price", 70);
summaryColumn.setSummaryType(SummaryType.SUM);


summaryColumn.setSummaryRenderer(new SummaryRenderer() {
public String render(Double value,
Map<String, Double> data) {
return value.toString();
}
});
summaryColumn.setAlignment(HorizontalAlignment.RIGHT);
summaryColumn.setNumberFormat(NumberFormat.getCurrencyFormat());


configs.add(summaryColumn);


DateField dateField = new DateField();
dateField.getPropertyEditor().setFormat(DateTimeFormat.getFormat("MM/dd/y"));


final GroupingStore store = new GroupingStore();
List<Plant> plants = new ArrayList<Plant>();
for (int i = 0; i < 4; i++) {
plants.add(new Plant("Bloodroot" +i, "Mostly Shady", 2.44, true));
plants.add(new Plant("Columbine"+i, "Shade", 9.37, true));
plants.add(new Plant("Marsh Marigold"+i, "Mostly Sunny", 6.81, false));
plants.add(new Plant("Cowslip"+i, "Mostly Shady", 9.90, true));
plants.add(new Plant("Dutchman's-Breeches"+i, "Mostly Shady", 6.44, true));
plants.add(new Plant("Ginger, Wild"+i, "Mostly Shady", 9.03, true));
plants.add(new Plant("Hepatica"+i, "Sunny", 4.45, true));
plants.add(new Plant("Liverleaf"+i, "Mostly Sunny", 3.99, true));
plants.add(new Plant("Jack-In-The-Pulpit"+i, "Mostly Shady", 3.23, true));
plants.add(new Plant("Mayapple"+i, "Mostly Shady", 2.98, true));
}
store.add(plants);


ColumnModel cm = new ColumnModel(configs);


GroupSummaryView gridView = new GroupSummaryView();
gridView.setShowGroupedColumn(false);


final Grid grid = new Grid(store, cm);
grid.setView(gridView);
grid.setAutoExpandColumn("name");
grid.setBorders(true);
return grid;
}


public void onModuleLoad() {
Viewport viewport = new Viewport();


viewport.setLayout(new FitLayout());
viewport.add(getGrid());


viewport.layout();
RootPanel.get().add(viewport);
}

When launching this test i have this error in Hosted mode:
[ERROR] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (TypeError): 'firstChild' a la valeur Null ou n'est pas un objet.
number: -2146823281
description: 'firstChild' a la valeur Null ou n'est pas un objet.
at com.google.gwt.dom.client.DOMImpl.getFirstChildElement(Native Method)
at com.google.gwt.dom.client.Element$.getFirstChildElement$(Element.java:98)
at com.extjs.gxt.ui.client.widget.grid.GroupSummaryView.doWidth(GroupSummaryView.java:94)
at com.extjs.gxt.ui.client.widget.grid.GroupSummaryView.templateOnColumnWidthUpdated(GroupSummaryView.java:207)
at com.extjs.gxt.ui.client.widget.grid.GridView.updateColumnWidth(GridView.java:1324)
at com.extjs.gxt.ui.client.widget.grid.GridView.autoExpand(GridView.java:512)
at com.extjs.gxt.ui.client.widget.grid.GridView.layout(GridView.java:421)
at com.extjs.gxt.ui.client.widget.grid.Grid.onAttach(Grid.java:321)
at com.extjs.gxt.ui.client.widget.ComponentHelper.doAttach(ComponentHelper.java:20)
at com.extjs.gxt.ui.client.widget.Container.doLayout(Container.java:258)
at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:341)
at com.extjs.gxt.ui.client.widget.LayoutContainer.layout(LayoutContainer.java:236)
at com.extjs.gxt.ui.client.widget.Container$1.execute(Container.java:351)
at com.google.gwt.user.client.CommandExecutor.doExecuteCommands(CommandExecutor.java:311)
at com.google.gwt.user.client.CommandExecutor$2.run(CommandExecutor.java:206)
at com.google.gwt.user.client.Timer.fireImpl(Timer.java:164)
at com.google.gwt.user.client.Timer.fireAndCatch(Timer.java:150)
at com.google.gwt.user.client.Timer.fire(Timer.java:142)

When i group by a column i have this error (without "gridView.setShowGroupedColumn(false)" it's OK):
[ERROR] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (TypeError): 'firstChild' a la valeur Null ou n'est pas un objet.
number: -2146823281
description: 'firstChild' a la valeur Null ou n'est pas un objet.
at com.google.gwt.dom.client.DOMImpl.getFirstChildElement(Native Method)
at com.google.gwt.dom.client.Element$.getFirstChildElement$(Element.java:98)
at com.extjs.gxt.ui.client.widget.grid.GroupSummaryView.templateOnColumnHiddenUpdated(GroupSummaryView.java:197)
at com.extjs.gxt.ui.client.widget.grid.GridView.updateColumnHidden(GridView.java:1299)
at com.extjs.gxt.ui.client.widget.grid.GridView.onHiddenChange(GridView.java:1071)
at com.extjs.gxt.ui.client.widget.grid.GridView$9.handleEvent(GridView.java:976)
at com.extjs.gxt.ui.client.widget.grid.GridView$9.handleEvent(GridView.java:1)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:74)
at com.extjs.gxt.ui.client.widget.grid.ColumnModel.setHidden(ColumnModel.java:391)
at com.extjs.gxt.ui.client.widget.grid.GroupingView.renderRows(GroupingView.java:403)
at com.extjs.gxt.ui.client.widget.grid.GridView.renderBody(GridView.java:1156)
at com.extjs.gxt.ui.client.widget.grid.GridView.refresh(GridView.java:433)
at com.extjs.gxt.ui.client.widget.grid.GridView.onDataChanged(GridView.java:1052)
at com.extjs.gxt.ui.client.widget.grid.GridView$6.storeDataChanged(GridView.java:923)
at com.extjs.gxt.ui.client.store.StoreListener.handleEvent(StoreListener.java:30)
at com.extjs.gxt.ui.client.store.StoreListener.handleEvent(StoreListener.java:1)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:74)
at com.extjs.gxt.ui.client.store.GroupingStore.groupBy(GroupingStore.java:117)
at com.extjs.gxt.ui.client.store.GroupingStore.groupBy(GroupingStore.java:77)
at com.extjs.gxt.ui.client.widget.grid.GroupingView.onGroupByClick(GroupingView.java:454)
at com.extjs.gxt.ui.client.widget.grid.GroupingView.access$0(GroupingView.java:453)
at com.extjs.gxt.ui.client.widget.grid.GroupingView$1.componentSelected(GroupingView.java:182)
at com.extjs.gxt.ui.client.widget.grid.GroupingView$1.componentSelected(GroupingView.java:1)
at com.extjs.gxt.ui.client.event.SelectionListener.handleEvent(SelectionListener.java:20)
at com.extjs.gxt.ui.client.event.SelectionListener.handleEvent(SelectionListener.java:1)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:74)
at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:423)
at com.extjs.gxt.ui.client.widget.menu.Item.onClick(Item.java:142)
at com.extjs.gxt.ui.client.widget.menu.Menu.onClick(Menu.java:537)
at com.extjs.gxt.ui.client.widget.menu.Menu.onComponentEvent(Menu.java:267)
at com.extjs.gxt.ui.client.widget.Component.onBrowserEvent(Component.java:655)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1308)
at com.google.gwt.user.client.DOM.dispatchEventAndCatch(DOM.java:1287)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1255)

This last error occured in Hosted/IE/Mozilla mode, after grouping the column the group is not displayed.

Thanks for your help

darrellmeyer
18 Sep 2008, 10:37 AM
The exception is caused when rendering the grid without grouping. In your code, you do not call groupBy on the grouping store. As a workaround, you could group the store. Fix is in SVN.

mike07
18 Sep 2008, 11:23 PM
thank you for your quick answer