Wednesday, September 15, 2010

How to handle celltable selection events?

I am using M3 and want to be able to click on a row of my table and be
able to listen for that event.

I have the following which works fine:

private SingleSelectionModel<DeviceInfo> setSelectionModel(
CellTable<DeviceInfo> cellTable) {
final SingleSelectionModel<DeviceInfo> selectionModel = new
SingleSelectionModel<DeviceInfo>();

Handler selectionHandler = new SelectionChangeEvent.Handler() {

@Override
public void onSelectionChange(
com.google.gwt.view.client.SelectionChangeEvent event) {
// User user = selectionModel.getSelectedObject();
dispatcher.execute(
getRealtimeAction(DEVICE_CHANNEL, selectionModel
.getSelectedObject().getDeviceId()),
new ActionCallback<RealtimeResult>() {

@Override
public void onFailure(Throwable caught) {
// do nothing
}

@Override
public void onSuccess(RealtimeResult result) {
// GWT.log("POSTED REALTIME");
}

});

DisplayMessageEvent.fireMessage(eventBus, "Loading...");

}

};


selectionModel.addSelectionChangeHandler(selectionHandler);
// cellTable.setSelectionEnabled(true);
cellTable.setSelectionModel(selectionModel);

return selectionModel;
}

The problem with this is that if the row is already selected you
cannot select it again. I want to fire the event not only
onSelectionChange but just Selection. Thanks.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment