PDA

View Full Version : [FIXED] TreeGrid and widget renderer



alacenaire
19 Jun 2009, 4:00 AM
Hi,

Is it not possible to add a widget renderer to a TreeGrid ?
It tried it and I have an error.

Thanks



Folder model = TestData.getTreeModel();

TreeStore<ModelData> store = new TreeStore<ModelData>();
store.add(model.getChildren(), true);

ColumnConfig name = new ColumnConfig("name", "Name", 100);
name.setRenderer(new TreeGridCellRenderer<ModelData>());

ColumnConfig date = new ColumnConfig("author", "Author", 100);

ColumnConfig size = new ColumnConfig("genre", "Genre", 100);

ColumnConfig btn = new ColumnConfig("button", "Button", 50);
btn.setRenderer(new TreeGridCellRenderer<ModelData>() {
@Override
public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
return new Button();
}
});

ColumnModel cm = new ColumnModel(Arrays.asList(name, date, size, btn));

ContentPanel cp = new ContentPanel();
cp.setBodyBorder(false);
cp.setHeading("TreeGrid");
cp.setButtonAlign(HorizontalAlignment.CENTER);
cp.setLayout(new FitLayout());
cp.setFrame(true);
cp.setSize(600, 300);

TreeGrid<ModelData> tree = new TreeGrid<ModelData>(store, cm);
tree.setBorders(true);
// tree.getStyle().setLeafIcon(Examples.ICONS.music());
tree.setSize(400, 200);
tree.setAutoExpandColumn("name");
tree.setTrackMouseOver(false);



[ERROR] Uncaught exception escaped
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.extjs.gxt.ui.client.widget.grid.GridView.getRenderedValue(GridView.java:963)
at com.extjs.gxt.ui.client.widget.grid.BufferView.doRender(BufferView.java:180)
at com.extjs.gxt.ui.client.widget.grid.BufferView.doRender(BufferView.java:158)
at com.extjs.gxt.ui.client.widget.grid.GridView.renderRows(GridView.java:1490)
at com.extjs.gxt.ui.client.widget.grid.GridView.insertRows(GridView.java:1179)
at com.extjs.gxt.ui.client.widget.grid.GridView.onAdd(GridView.java:1230)
at com.extjs.gxt.ui.client.widget.grid.GridView$5.storeAdd(GridView.java:1112)
at com.extjs.gxt.ui.client.store.StoreListener.handleEvent(StoreListener.java:22)
at com.extjs.gxt.ui.client.store.StoreListener.handleEvent(StoreListener.java:1)
at com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:176)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:96)
at com.extjs.gxt.ui.client.store.ListStore.insert(ListStore.java:453)
at com.extjs.gxt.ui.client.store.ListStore.insert(ListStore.java:262)
at com.extjs.gxt.ui.client.store.ListStore.add(ListStore.java:147)
at com.extjs.gxt.ui.client.widget.treegrid.TreeGrid.renderChildren(TreeGrid.java:519)
at com.extjs.gxt.ui.client.widget.treegrid.TreeGrid.afterRenderView(TreeGrid.java:353)
at com.extjs.gxt.ui.client.widget.grid.Grid$1.run(Grid.java:554)
at com.google.gwt.user.client.Timer.fireImpl(Timer.java:160)
at com.google.gwt.user.client.Timer.fireAndCatch(Timer.java:146)
at com.google.gwt.user.client.Timer.fire(Timer.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.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.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:235)
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)

darrellmeyer
19 Jun 2009, 12:09 PM
It is now possible use widgets with TreeGrid. Also, we have just added WidgetTreeGridCellRenderer which allows you to add widgets to the column with the tree. You can see a demo here http://extjs.com/examples-dev/explorer.html#widgetrenderertreegrid. The new code is in SVN.