Thursday, December 30, 2010

Dynamically update the contents of a SelectionCell dropdown list

I am trying to have a table that displays data that the user inputs as
well as edit the data. I have figured out how to do this with text
(ie, they can edit the name of something in the table), but I cannot
get it to work with selection cells.

It works correctly if the items in the selection cell are predefined,
but I cannot dynamically update the items in the cell to include new
things after I have created the cell.

To explain more, i have a "type" column. The user enters items into
the table with a given type, but that can also add new types later.
When they click on the item in the type column, I want the dropdown
box to contain all the new types that they have entered, but I don't
know how to accomplish this.

Here is the code I have so far (that doesn't update like I want it
to). record.getTypeList() will contain additional entries after the
user enters new types.

SelectionCell editTypeComboBox = new
SelectionCell(record.getTypeList());

Column<Assignment, String> typeColumn = new Column<Assignment,
String>(editTypeComboBox) {
@Override
public String getValue(Assignment object) {
return object.getType();
}
};
typeColumn.setFieldUpdater(new FieldUpdater<Assignment, String>()
{

@Override
public void update(int index, Assignment object, String value)
{
int row = index;
String newType = value;
record.editAssignType(row, newType);
updateClassGradeLabel();
log.info("Set type to "
+ value);
cellTable.redraw();
}
});

cellTable.addColumn(typeColumn, "Type");

Does anyone have any ideas on how to accomplish this?

--
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate