PDA

View Full Version : trying to hide column of Grid prior to first rendering, errors...



nbuesing
31 Jan 2012, 9:16 AM
I have a grid where I'm hiding/showing columns. Now if I add a UI component that does this code within a value change handler everything works find. However, if I try to hide a column upon construction, it doesn't work.

Scenario 1 : add the following in after the grid is created:


view.groupBy(grid.getColumnModel().findColumnConfig("id"));

I get a null pointer error in GroupingView.groupBy(ColumnConfig<M, ?> column)


if (grid.getLoader() == null || !grid.getLoader().isRemoteSort()) {



Scenario 2: try to change the column hidden state with a scheduler as shown:




Scheduler.get().scheduleFinally(new ScheduledCommand() {
@Override
public void execute() {
ColumnModel<Row> cm = grid.getColumnModel();
ColumnConfig<Row, ?> config = cm.findColumnConfig("id");
config.setHidden(hide);
}
});


When that happens, I get this stack trace.




com.google.gwt.core.client.JavaScriptException: (TypeError): 'style' is null or not an object
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248)
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.sencha.gxt.core.client.dom.impl.ComputedStyleImplIE.getComputedStyle(ComputedStyleImplIE.java)
at com.sencha.gxt.core.client.dom.impl.ComputedStyleImplIE.getStyleAttribute(ComputedStyleImplIE.java:12)
at com.sencha.gxt.core.client.dom.XElement$.getComputedStyle$(XElement.java:692)
at com.sencha.gxt.core.client.dom.XElement$.getFrameWidth$(XElement.java:786)
at com.sencha.gxt.widget.core.client.grid.ColumnHeader$Head.updateWidth(ColumnHeader.java:344)
at com.sencha.gxt.widget.core.client.grid.ColumnHeader.updateColumnWidth(ColumnHeader.java:930)
at com.sencha.gxt.widget.core.client.grid.GridView.updateAllColumnWidths(GridView.java:2397)
at com.sencha.gxt.widget.core.client.grid.GridView.fitColumns(GridView.java:1247)
at com.sencha.gxt.widget.core.client.grid.GridView.layout(GridView.java:1718)
at com.sencha.gxt.widget.core.client.grid.GridView.layout(GridView.java:626)
at com.sencha.gxt.widget.core.client.grid.Grid.onResize(Grid.java:1095)
at com.sencha.gxt.widget.core.client.Component.setPixelSize(Component.java:840)
at com.sencha.gxt.widget.core.client.container.ResizeContainer.applyLayout(ResizeContainer.java:74)
at com.sencha.gxt.widget.core.client.container.SimpleContainer.doLayout(SimpleContainer.java:94)
at com.sencha.gxt.widget.core.client.container.ResizeContainer.forceLayout(ResizeContainer.java:46)
at com.sencha.gxt.widget.core.client.container.ResizeContainer.forceLayoutOnChildren(ResizeContainer.java:117)
at com.sencha.gxt.widget.core.client.container.ResizeContainer.forceLayout(ResizeContainer.java:48)
at com.sencha.gxt.widget.core.client.container.ResizeContainer.forceLayoutOnChildren(ResizeContainer.java:117)
at com.sencha.gxt.widget.core.client.container.ResizeContainer.forceLayout(ResizeContainer.java:48)
at com.sencha.gxt.widget.core.client.container.ResizeContainer.forceLayoutOnChildren(ResizeContainer.java:117)
at com.sencha.gxt.widget.core.client.container.ResizeContainer.forceLayout(ResizeContainer.java:48)
at com.sencha.gxt.widget.core.client.container.ResizeContainer$1.execute(ResizeContainer.java:23)
at com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50)
at com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:228)
at com.google.gwt.core.client.impl.SchedulerImpl.flushFinallyCommands(SchedulerImpl.java:327)
at com.google.gwt.core.client.impl.Impl.exit(Impl.java:237)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:228)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
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:736)