You can create a Column with a ButtonCell as follows:
ButtonCell buttonCell = new ButtonCell();
Column buttonColumn = new Column<DocumentDetailsDTO, String>(buttonCell) {
@Override
public String getValue(DocumentDetailsDTO object) {
public String getValue(DocumentDetailsDTO object) {
// The value to display in the button.
return object.getName();
}
return object.getName();
}
}
table.addColumn(buttonColumn, "Action");
You can then set a FieldUpdater on the Column to be notified of clicks.
buttonColumn.setFieldUpdater(new FieldUpdater<DocumentDetailsDTO, String>() {
public void update(int index, DocumentDetailsDTO object, String value) {
// Value is the button value. Object is the row object.
Window.alert("You clicked: " + value);
}
});
Thanks,
John LaBanca
jlabanca@google.com
On Thu, Oct 28, 2010 at 5:26 AM, dave_mcgee <daveomcgee@gmail.com> wrote:
Hi there,
I'm wondering if anyone could assist me with adding buttons to columns
within CellTables? I can do TextColumns fine but I'm experiencing
issues adding a button I've defined. So its been working fine with the
text using the code at the end.. but i want to do this:
// create a column for a download button
// add the button to the column
// add the column to the table
Any ideas much apreciated!
--
(This works fine for text..)
documentColumn = new TextColumn<DocumentDetailsDTO>() {
@Override
public String getValue(DocumentDetailsDTO object) {
return object.getName();
}
};
table.addColumn(documentColumn, "File");
Regards,
Dave.
--
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.
--
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