2015-02-05 62 views
0

我正在使用GXT3.1.2/GWT2.6 我想將複選框添加到TreeGrid中,但效果不佳。 當我點擊複選框時,該行中的所有值都變爲「true」。 而當我再次點擊時,它會引發異常。請幫忙。GXT:如何將複選框添加到TreeGrid中?

這裏是我的代碼:

ColumnConfig<OBTInputTuple, Boolean> cc3 = new ColumnConfig<OBTInputTuple, Boolean>(new ValueProvider<OBTInputTuple, Boolean>(){ 
     @Override 
     public Boolean getValue(OBTInputTuple object) { 
      return object.isMandatory(); 
     } 

     @Override 
     public void setValue(OBTInputTuple object, Boolean value) { 
      object.setMandatory(value); 
     } 

     @Override 
     public String getPath() { 
      return null; 
     } 
    }); 
    cc3.setCell(new CheckBoxCell()); 
    cc3.setWidth(200); 
    cc3.setHeader("Mandatory"); 

當我點擊一次複選框: enter image description here

當我再次點擊複選框:

com.google.gwt.event.shared.UmbrellaException: Exception caught: Item was not already in the store, cannot be updated 
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129) 
    at com.sencha.gxt.data.shared.Store.fireEvent(Store.java:610) 
    at com.sencha.gxt.data.shared.Store$Record.addChange(Store.java:174) 
    at com.sencha.gxt.widget.core.client.grid.Grid$2.update(Grid.java:878) 
    at com.sencha.gxt.cell.core.client.form.CheckBoxCell.onBrowserEvent(CheckBoxCell.java:171) 
    at com.sencha.gxt.cell.core.client.form.CheckBoxCell.onBrowserEvent(CheckBoxCell.java:1) 
    at com.sencha.gxt.widget.core.client.grid.Grid.fireEventToCell(Grid.java:875) 
    at com.sencha.gxt.widget.core.client.grid.Grid.handleEventForCell(Grid.java:907) 
    at com.sencha.gxt.widget.core.client.grid.Grid.onBrowserEvent(Grid.java:594) 
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1467) 
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1406) 
    at com.google.gwt.user.client.impl.DOMImplStandard.dispatchEvent(DOMImplStandard.java:323) 
    at sun.reflect.GeneratedMethodAccessor144.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    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:338) 
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219) 
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) 
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:576) 
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:284) 
    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:347) 
    at sun.reflect.GeneratedMethodAccessor140.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    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:293) 
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547) 
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364) 
    at java.lang.Thread.run(Unknown Source) 
Caused by: java.lang.AssertionError: Item was not already in the store, cannot be updated 
    at com.sencha.gxt.data.shared.ListStore.update(ListStore.java:370) 
    at com.sencha.gxt.widget.core.client.treegrid.TreeGrid.onRecordChange(TreeGrid.java:1030) 
    at com.sencha.gxt.widget.core.client.treegrid.TreeGrid$1.onRecordChange(TreeGrid.java:253) 
    at com.sencha.gxt.data.shared.event.StoreRecordChangeEvent.dispatch(StoreRecordChangeEvent.java:113) 
    at com.sencha.gxt.data.shared.event.StoreRecordChangeEvent.dispatch(StoreRecordChangeEvent.java:1) 
    at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1) 
    at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40) 
    at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193) 
    at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88) 
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127) 
    at com.sencha.gxt.data.shared.Store.fireEvent(Store.java:610) 
    at com.sencha.gxt.data.shared.Store$Record.addChange(Store.java:174) 
    at com.sencha.gxt.widget.core.client.grid.Grid$2.update(Grid.java:878) 
    at com.sencha.gxt.cell.core.client.form.CheckBoxCell.onBrowserEvent(CheckBoxCell.java:171) 
    at com.sencha.gxt.cell.core.client.form.CheckBoxCell.onBrowserEvent(CheckBoxCell.java:1) 
    at com.sencha.gxt.widget.core.client.grid.Grid.fireEventToCell(Grid.java:875) 
    at com.sencha.gxt.widget.core.client.grid.Grid.handleEventForCell(Grid.java:907) 
    at com.sencha.gxt.widget.core.client.grid.Grid.onBrowserEvent(Grid.java:594) 
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1467) 
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1406) 
    at com.google.gwt.user.client.impl.DOMImplStandard.dispatchEvent(DOMImplStandard.java:323) 
    at sun.reflect.GeneratedMethodAccessor144.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    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:338) 
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219) 
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) 
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:576) 
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:284) 
    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:347) 
    at sun.reflect.GeneratedMethodAccessor140.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    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:293) 
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547) 
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364) 
    at java.lang.Thread.run(Unknown Source) 

回答

2

最後我想通了! 這是因爲
@Override public String getPath(){ return null; }

我應該讓它返回一個字符串值而不是null。 一旦我做到了。一切都很完美。

相關問題