Hi:
I want to try the DataGrid in 2.4 RC1 release. I took the CellTable example and slightly modified it to use DataGrid. I could compile fine but nothing gets displayed in the browser and no exceptions. I don't know why it is not working.
Appreciate your help. Thanks.
NR
public class DataGridExample implements EntryPoint {
private static class Contact {
private final String address;
private final Date birthday;
private final String name;
public Contact(String name, Date birthday, String address) {
this.name = name;
this.birthday = birthday;
this.address = address;
}
}
private static final List<Contact> CONTACTS = Arrays.asList(
new Contact("John", new Date(80, 4, 12), "123 Fourth Avenue"),
new Contact("Joe", new Date(85, 2, 22), "22 Lance Ln"),
new Contact("George", new Date(46, 6, 6), "1600 Pennsylvania Avenue"));
public void onModuleLoad() {
DataGrid<Contact> table = new DataGrid<Contact>();
table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
TextColumn<Contact> nameColumn = new TextColumn<Contact>() {
@Override
public String getValue(Contact object) {
return
object.name;
}
};
table.addColumn(nameColumn, "Name");
DateCell dateCell = new DateCell();
Column<Contact, Date> dateColumn = new Column<Contact, Date>(dateCell) {
@Override
public Date getValue(Contact object) {
return object.birthday;
}
};
table.addColumn(dateColumn, "Birthday");
TextColumn<Contact> addressColumn = new TextColumn<Contact>() {
@Override
public String getValue(Contact object) {
return object.address;
}
};
table.addColumn(addressColumn, "Address");
final SingleSelectionModel<Contact> selectionModel = new SingleSelectionModel<Contact>();
table.setSelectionModel(selectionModel);
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
public void onSelectionChange(SelectionChangeEvent event) {
Contact selected = selectionModel.getSelectedObject();
if (selected != null) {
Window.alert("You selected: " +
selected.name);
}
}
});
table.setRowCount(CONTACTS.size(), true);
table.setRowData(0, CONTACTS);
RootPanel.get().add(table);
}
}