PDA

View Full Version : [2.0] Select a Grid-Row before rendered



netRapid
22 Jul 2009, 5:59 AM
Hello,

I would like to select the first row of a Grid when the application has started (Store is loaded):


grid.getSelectionModel().select(offers.getStore().getAt(0), true);

Produce the follow Exception:


java.lang.NullPointerException: null
at com.extjs.gxt.ui.client.widget.grid.GridView.hasRows(GridView.java:1841)
at com.extjs.gxt.ui.client.widget.grid.GridView.getRows(GridView.java:1019)
at com.extjs.gxt.ui.client.widget.grid.GridView.getRow(GridView.java:386)
at com.extjs.gxt.ui.client.widget.grid.GridView.onRowSelect(GridView.java:1421)
at com.extjs.gxt.ui.client.widget.grid.GridSelectionModel.onSelectChange(GridSelectionModel.java:311)
at com.extjs.gxt.ui.client.widget.selection.AbstractStoreSelectionModel.doMultiSelect(AbstractStoreSelectionModel.java:298)
at com.extjs.gxt.ui.client.widget.selection.AbstractStoreSelectionModel.doSelect(AbstractStoreSelectionModel.java:314)
at com.extjs.gxt.ui.client.widget.selection.AbstractStoreSelectionModel.select(AbstractStoreSelectionModel.java:228)
at com.extjs.gxt.ui.client.widget.selection.AbstractStoreSelectionModel.select(AbstractStoreSelectionModel.java:236)
at de.netrapid.b2b.client.mvc.productdetail.ProductDetailView.onShow(ProductDetailView.java:120)
at de.netrapid.b2b.client.mvc.productdetail.ProductDetailView.handleEvent(ProductDetailView.java:57)
at com.extjs.gxt.ui.client.mvc.Controller.forwardToView(Controller.java:90)
at de.netrapid.b2b.client.mvc.productdetail.ProductDetailController$1.success(ProductDetailController.java:74)
at de.netrapid.b2b.client.mvc.productdetail.ProductDetailController$1.success(ProductDetailController.java:1)
at de.netrapid.b2b.client.util.B2BAsyncCallback.onSuccess(B2BAsyncCallback.java:43)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:215)
at com.google.gwt.http.client.Request.fireOnResponseReceivedImpl(Request.java:264)
at com.google.gwt.http.client.Request.fireOnResponseReceivedAndCatch(Request.java:236)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:227)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.mac.MethodDispatch.invoke(MethodDispatch.java:71)
at org.eclipse.swt.internal.carbon.OS.ReceiveNextEvent(Native Method)
at org.eclipse.swt.widgets.Display.sleep(Display.java:3801)
at com.google.gwt.dev.SwtHostedModeBase.sleep(SwtHostedModeBase.java:241)
at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:236)
at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:558)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)


Cheers
Bernhard

sven
22 Jul 2009, 6:11 AM
Also use the forumsearch, there are a couple of threads how to select a gridrow. Moving this to the help forum.

you need to listen to the new ViewReady event of grid and then select your rows.

netRapid
22 Jul 2009, 6:31 AM
ok thx. the ViewReady event is in svn only.

sven
22 Jul 2009, 6:37 AM
Yes, we added this as this was reporeted before.