PDA

View Full Version : [FIXED] Removing an element from a grid store throws exception



yleguern
27 Aug 2008, 11:50 PM
Hello,

When you remove an element from the store of a grid, selection is disabled and an exception is thrown :


[ERROR] Uncaught exception escaped
java.lang.ArrayIndexOutOfBoundsException: -1
at com.extjs.gxt.ui.client.widget.grid.GridView.getRow(GridView.java:291)
at com.extjs.gxt.ui.client.widget.grid.GridView.onRowDeselect(GridView.java:1088)
at com.extjs.gxt.ui.client.widget.grid.GridSelectionModel.onSelectChange(GridSelectionModel.java:152)
at com.extjs.gxt.ui.client.widget.selection.AbstractStoreSelectionModel.doDeselect(AbstractStoreSelectionModel.java:178)
at com.extjs.gxt.ui.client.widget.selection.AbstractStoreSelectionModel.doSingleSelect(AbstractStoreSelectionModel.java:226)
at com.extjs.gxt.ui.client.widget.selection.AbstractStoreSelectionModel.doSelect(AbstractStoreSelectionModel.java:210)
at com.extjs.gxt.ui.client.widget.selection.AbstractStoreSelectionModel.select(AbstractStoreSelectionModel.java:155)
at com.extjs.gxt.ui.client.widget.selection.AbstractStoreSelectionModel.select(AbstractStoreSelectionModel.java:163)
at com.extjs.gxt.ui.client.widget.grid.GridSelectionModel.handleMouseDown(GridSelectionModel.java:95)
at com.extjs.gxt.ui.client.widget.grid.GridSelectionModel.handleEvent(GridSelectionModel.java:69)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:74)
at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:420)
at com.extjs.gxt.ui.client.widget.grid.Grid.onMouseDown(Grid.java:532)
at com.extjs.gxt.ui.client.widget.grid.Grid.onComponentEvent(Grid.java:335)
at com.extjs.gxt.ui.client.widget.Component.onBrowserEvent(Component.java:657)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1388)
at com.google.gwt.user.client.DOM.dispatchEventAndCatch(DOM.java:1367)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1321)
at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
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.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.GWTShell.pumpEventLoop(GWTShell.java:721)
at com.google.gwt.dev.GWTShell.run(GWTShell.java:594)
at com.google.gwt.dev.GWTShell.main(GWTShell.java:358)My code :



public class Test implements EntryPoint {
public void onModuleLoad() {
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
configs.add(new ColumnConfig("c1", "Column 1", 150));
configs.add(new ColumnConfig("c2", "Column 2", 150));
ColumnModel cm = new ColumnModel(configs);

ListStore<MyModel> store = new ListStore<MyModel>();
for (int i = 0; i < 20; i++) {
store.add(new MyModel("c1-" + (i+1), "c2-" + (i+1)));
}

final Grid<MyModel> grid = new Grid<MyModel>(store, cm);
grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
grid.setBorders(true);
grid.setSize(324, 300);
RootPanel.get().add(grid);

Button removeItem = new Button("Remove", new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
MyModel l_selectedValue = grid.getSelectionModel().getSelectedItem();
if(l_selectedValue != null) {
grid.getStore().remove(l_selectedValue);
}
}
});
RootPanel.get().add(removeItem);
}
public static class MyModel extends BaseModel
{
public MyModel(String value1, String value2)
{
set("c1", value1);
set("c2", value2);
}
}
}My config :
gxt-1.1-alpha2
Windows XP
Host mode / EclipseThanks,
Yann.

darrellmeyer
28 Aug 2008, 9:02 AM
Fixed in SVN.