PDA

View Full Version : Editor Grid change value of other cells on change in value of a cell.



AV_SW_WGMT_01
4 Nov 2012, 12:13 AM
Hi,

Task: [version:2.2.5] I am using an editor grid.
When I change the value of a cell (a combo value), I want the value of other cells to be changed as per my programming logic.

Approach:
I've applied selectionChangeListener on combo.

In selection change:
1. Get the record from the grid.getSelectionModel().getSelection()
2. Make changes in the record as per my logic.
3. update the grid with the record: grid.getStore().update();
4. [Problem] Only the combo value is reflected as changed value(modified record) and the other values of other cells are changed but not reflected as "changed value".

Code inside the combo selection change.


List<MyRecord> list = grid.getSelectionModel().getSelection();
if (list == null) {
return;
}
MyRecord originalRecord = list.get(0);


MyRecord tempRecord = new MyRecord();
tempRecord.setGUID(originalRecord.getGUID());


String changedValue = (String) se.getSelectedItem().get("value");
if (changedValue.equals(originalRecord.getApplication())) {
// Do nothing, as data has not changed.
return;
}


int portNumber = 0;
switch (ApplicationType.getId(changedValue)) {
case 1:
portNumber = 50791;
break;
case 2:
portNumber = 8080;
break;
case 3:
portNumber = 22;
break;
case 4:
portNumber = 23;
break;
case 5:
portNumber = 3389;
break;
case 6:
portNumber = 0;
break;
case 7:
portNumber = 7070;
break;
}


tempRecord.setApplication(changedValue);
tempRecord.setInternalIpAddress("0.0.0.0"); // common value for all types.
tempRecord.setProtocol(ProtocolType.getName(2)); // TCP is default protocol
tempRecord.setExternalPortNumber(portNumber); // specific port number
tempRecord.setInternalPortNumber(portNumber); // specific port number


grid.getStore().update(tempRecord);



Any help is appreciated.

Thanks,
Deep