PDA

View Full Version : Combo Box and Editor Grid-Retrieve data



Quarks
7 Dec 2011, 3:16 AM
I have an editor grid with a combo box as one of the columns. I want to retrieve the modified records data from the editor grid.
In my save function the code is as follows:

depcp.addButton(new Button("Save", new SelectionListener<ButtonEvent>() {

@Override
public void componentSelected(ButtonEvent ce) {
List<Record> records=depstore.getModifiedRecords();
for(Record r:records)
{
BaseModelData w = (BaseModelData) r.getModel();
MessageBox.prompt(w.get("table_id").toString(), (String)w.get("table_buf"));
combo.getValue().get("table_id").toString());
}
}
}));


So the modified records correctly show the rows that have been edited. But I get the existing value(I am giving defaults for the combobox) and not the edited value(which the user enters from the dropdown).
How do I get the edited value here? Basically, I should be getting to the store of the combobox and not the grid, right?

I have overridden the combobox preprocess and postprocess as follows:


combo.setDisplayField("feed_name");
combo.setValueField("table_id");
CellEditor editor = new CellEditor(combo) {
@Override
public Object preProcessValue(Object value) {
if (value == null) {
return value;
}
return combo.getStore().findModel(combo.getDisplayField(), value.toString());


}

@Override
public Object postProcessValue(Object value) {
if (value == null) {
return value;
}
((BaseModelData)value).set("table_id",combo.getValue().getTable_id());
return ((BaseModelData) value).get(combo.getDisplayField());
}
};

My display field is the name and the value field is the id of the underlying basemodel object. I want to be able to get the id of the modified entry in the combobox.
And for the column config I have:


depcolumn.setId("feed_name");

Thanks in advance!