PDA

View Full Version : Update grid cell with ComboBox edited value



deep26
15 Jun 2009, 11:46 AM
I have added a ComboBox as an Editor to one of my Grid column. The combo box is editable. I am populating the combo using a store. Now my requirement is that if the user makes any changes to any of the items in the Combo then that changed value should get written to that cell where the Combo box appeared.

For E.g:
I am row 1, col 3. I click the cell my combo shows up with values :
- Hello 1
- Hello 2

Now i change Hello 2 to "Hello World". Now I want "Hello World" to be written back to row1, col3.

I am not able to get this feature working.
I looked into the demo examples but I dont see such a feature.
If I dont make a change in the Combo and just select the existing values it gets written to the corresponding cell.

Is it possible to achieve this ? If yes please suggest me how can I do this.

fother
15 Jun 2009, 1:16 PM
in http://www.extjs.com/examples-dev/explorer.html#editablegrid look for this piece of code..



final SimpleComboBox<String> combo = new SimpleComboBox<String>();
combo.setForceSelection(true);
combo.setTriggerAction(TriggerAction.ALL);
combo.add("Shade");
combo.add("Mostly Shady");
combo.add("Sun or Shade");
combo.add("Mostly Sunny");
combo.add("Sunny");

CellEditor editor = new CellEditor(combo) {
@Override
public Object preProcessValue(Object value) {
if (value == null) {
return value;
}
return combo.findModel(value.toString());
}

@Override
public Object postProcessValue(Object value) {
if (value == null) {
return value;
}
return ((ModelData) value).get("value");
}
};


you can get the instance of store of the grid (set store attribute of the class).. set the new value