PDA

View Full Version : [FIXED] Grid selection model does not fire selection event when mode is SINGLE



yleguern
28 Aug 2008, 1:32 AM
The grid selection model does not fire selection events when selection is empty and you select a row (when selection mode is SINGLE) :


public class App 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);
final Text status = new Text();
status.setStyleName("text");
RootPanel.get().add(status);

grid.getSelectionModel().addListener(Events.SelectionChange, new Listener<SelectionEvent<MyModel>>() {
public void handleEvent(SelectionEvent<MyModel> in_event) {
System.out.println("selection changed");
status.setText("Selected item : " + (in_event.selection.size()>0?in_event.selection.get(0):"none"));
}
});
}


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, 7:53 AM
Fix is in SVN.