PDA

View Full Version : RowEditor plugin do not hide after save button clicked.



chemkb
22 Oct 2011, 1:45 PM
I have crated multiple Grids from a single GroupingStore. Grids have GroupSummaryView as view. I want to use RowEditor plugin but having some issues implementing it. Below how you can reproduce my issue:

Goto: http://compressor-calculations.appspot.com/

1. add a row using the add item button on tool bar, once all the fileds are filled with valid input click save. it will save the values to the grid and row editor will exit.
2. Click save button at the bottom of the panel again to commit to the store.

2. Now add another row using the add item button on tool bar, once all the fileds are filled with valid input click save but this time values will be not saved and editor will not exit.

Below is the excerpt of my code.

public class LineItemGrid<BaseModel> extends LayoutContainer {
final GroupingStore<LineItemModel> store = new GroupingStore<LineItemModel>();
public LineItemGrid() {
setLayout(new FlowLayout(5));
store.groupBy("section");
final RowEditor<LineItemModel> re = new RowEditor<LineItemModel>();
final Grid<LineItemModel> gridGen = new Grid<LineItemModel>(store, getColumnModelGen());
GroupSummaryView summary = new GroupSummaryView();
summary.setForceFit(true);
summary.setShowGroupedColumn(true);
summary.setSortingEnabled(false);
summary.setGroupRenderer(new GridGroupRenderer() {
public String render(GroupColumnData data) {
return "Section " + data.group;
}
});
gridGen.setView(summary);
gridGen.getView().setShowDirtyCells(true);
//gridGen.getView().setShowInvalidCells(true);
gridGen.setAutoExpandColumn("volume");
gridGen.setBorders(true);
gridGen.setStripeRows(true);
gridGen.setColumnLines(true);
gridGen.setLoadMask(true);
gridGen.addPlugin(re);
final ColumnModel cmVol = new ColumnModel(getcolumnConfigVolume());
final EditorGrid<LineItemModel> gridVolume = new EditorGrid<LineItemModel>(store, cmVol);
final ColumnModel cmCalc = new ColumnModel(getcolumnConfigCalc());
final EditorGrid<LineItemModel> gridCalculation = new EditorGrid<LineItemModel>(store, cmCalc);
ContentPanel cp = new ContentPanel();
cp.setIcon(Resources.ICONS.table());
cp.setHeading("Compressor Settel Out Calculation v1.0 Beta");
cp.setFrame(true);
cp.setSize(990, 400);
cp.setLayout(new FitLayout());
cp.setHeaderVisible(false);
cp.add(gridGen);
ToolBar toolBar = new ToolBar();
Button add = new Button("Add Item");
add.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
LineItemModel item = new LineItemModel();
item.setVolume(0.0);
item.setInventory(0.0);
item.setNormalVolumn(0.0);
item.setMoles(0.0);
item.setMolesT(0.0)
//gridGen.stopEditing();
//store.insert(item, store.getCount());
//gridGen.startEditing(store.indexOf(item), 0);
re.stopEditing(true);
store.insert(item, store.getCount());
re.startEditing(store.indexOf(item), true);
gridGen.repaint();
}
});
Error: (:|
16:28:28.327 [ERROR] [settleoutcalcsext] Uncaught exception escaped
com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
at com.google.gwt.user.client.Event$NativePreviewEvent.fire(Event.java:87)
at com.google.gwt.user.client.Event$NativePreviewEvent.access$4(Event.java:73)
at com.google.gwt.user.client.Event$.fireNativePreviewEvent(Event.java:488)
at com.google.gwt.user.client.DOM.previewEvent(DOM.java:1328)
at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)

chemkb
22 Oct 2011, 6:21 PM
Ok I think I found the problem. If i remove GroupSummaryView from grid then RowEditor works as it suppose to.

/*gridGen.setView(new GroupSummaryView()); */

I am still investigating why? Please help!!

Ravi

chemkb
22 Oct 2011, 6:44 PM
Ok..I am sure that GroupSummaryView is creating issues with RowEditor. When I switch to GroupingView RowEditor works fine.

Is this a Bug or I am doing something wrong!!

Ravi

Colin Alworth
23 Oct 2011, 6:20 AM
Error: (:|
16:28:28.327 [ERROR] [settleoutcalcsext] Uncaught exception escaped
com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
at com.google.gwt.user.client.Event$NativePreviewEvent.fire(Event.java:87)
at com.google.gwt.user.client.Event$NativePreviewEvent.access$4(Event.java:73)
at com.google.gwt.user.client.Event$.fireNativePreviewEvent(Event.java:488)
at com.google.gwt.user.client.DOM.previewEvent(DOM.java:1328)
at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)

Can you post the rest of the exception? This is wrapping the real exception, which probably has some useful info about what actually is going wrong.

chemkb
23 Oct 2011, 9:29 AM
Colin,

I have changed my code since i reported the issue. But i have created a test case to reproduce it. Below is the trace and the code to reproduce it.

12:17:28.642 [ERROR] [settleoutcalcsext] Uncaught exception escaped


java.lang.NullPointerException: null
at com.extjs.gxt.ui.client.data.BaseModelData.get(BaseModelData.java:51)
at com.extjs.gxt.ui.client.widget.grid.GroupSummaryView.onUpdate(GroupSummaryView.java:163)
at com.extjs.gxt.ui.client.widget.grid.GridView$6.storeUpdate(GridView.java:1338)
at com.extjs.gxt.ui.client.store.StoreListener.handleEvent(StoreListener.java:36)
at com.extjs.gxt.ui.client.store.StoreListener.handleEvent(StoreListener.java:1)
at com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:178)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:86)
at com.extjs.gxt.ui.client.store.ListStore.fireStoreEvent(ListStore.java:467)
at com.extjs.gxt.ui.client.store.Store.afterEdit(Store.java:588)
at com.extjs.gxt.ui.client.store.Record.endEdit(Record.java:135)
at com.extjs.gxt.ui.client.widget.grid.RowEditor.stopEditing(RowEditor.java:502)
at com.extjs.gxt.ui.client.widget.grid.RowEditor$7.componentSelected(RowEditor.java:572)
at com.extjs.gxt.ui.client.widget.grid.RowEditor$7.componentSelected(RowEditor.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.callListener(BaseObservable.java:178)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:86)
at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:456)
at com.extjs.gxt.ui.client.widget.button.Button.onClick(Button.java:616)
at com.extjs.gxt.ui.client.widget.button.Button.onComponentEvent(Button.java:288)
at com.extjs.gxt.ui.client.widget.Component.onBrowserEvent(Component.java:884)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
at sun.reflect.GeneratedMethodAccessor73.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:680)


///----------------------Test Code--------------
package com.ckb.client;
import java.util.ArrayList;

public class Test extends LayoutContainer {
public Test() {
setLayout(new FlowLayout(5));
final GroupingStore<State> store = new GroupingStore<State>();
final RowEditor<State> re = new RowEditor<State>();
List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); SummaryColumnConfig<Double> columnName = new SummaryColumnConfig<Double>("name", "Name#", 40);
columnName.setAlignment(HorizontalAlignment.CENTER);
TextField<String> textName = new TextField<String>();
textName.setAllowBlank(false);
columnName.setEditor(new CellEditor(textName));
configs.add(columnName);
final ColumnModel cmGen = new ColumnModel(configs);
final Grid<State> gridGen = new Grid<State>(store,cmGen );
GroupSummaryView summary = new GroupSummaryView();
summary.setForceFit(true);
//summary.setShowGroupedColumn(true);
//summary.setSortingEnabled(false);
summary.setGroupRenderer(new GridGroupRenderer() {
public String render(GroupColumnData data) {
return "Section " + data.group;
}
});
gridGen.setView(new GroupSummaryView());
gridGen.getView().setShowDirtyCells(true);
gridGen.getView().setShowInvalidCells(true);
gridGen.setAutoExpandColumn("name");
gridGen.setBorders(true);
gridGen.setStripeRows(true);
gridGen.setColumnLines(true);
gridGen.setLoadMask(true);
gridGen.addPlugin(re);
ContentPanel cp = new ContentPanel();
cp.setHeading("Calculation v1.0 Beta");
cp.setFrame(true);
cp.setSize(990, 400);
cp.setLayout(new FitLayout());
cp.setHeaderVisible(false);
cp.add(gridGen);
ToolBar toolBar = new ToolBar();
Button add = new Button("Add Item");
add.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
State item = new State();
//gridGen.stopEditing();
//store.insert(item, store.getCount());
//gridGen.startEditing(store.indexOf(item), 0);
re.stopEditing(true);
store.insert(item, store.getCount());
re.startEditing(store.indexOf(item), true);
}
});

Button remove = new Button("Remove Item");
remove.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
store.remove(gridGen.getSelectionModel().getSelectedItem());
}
});
toolBar.add(add);
toolBar.add(remove);
cp.setTopComponent(toolBar);
cp.setButtonAlign(HorizontalAlignment.CENTER);
cp.addButton(new Button("Reset", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
store.rejectChanges();
} }));
cp.addButton(new Button("Save", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
store.commitChanges();
//store.groupBy("section", true);
}}));
TabPanel folder = new TabPanel();
folder.setWidth(990);
folder.setHeight(450);
folder.setBorders(true);
TabItem tabGeneral = new TabItem("General");
tabGeneral.add(cp);
folder.add(tabGeneral);
tabGeneral.setHeight("400px");
add(folder);
}}


/////////////////////////Model////////////////
import com.extjs.gxt.ui.client.data.BaseModelData;
public class State extends BaseModelData {


public State() {
}
public State( String name) {
setName(name);
}
public String getName() {
return get("name");
}
public void setName(String name) {
set("name", name);
}}