Hello,
We upgraded our application from 4.0p (NIGHTLY 2014-02-12) to 5.0p (NIGHTLY-2015-04-15) and we have an issue with reset old value on a field.
If you run the example and you edit field "Country" and press tab to navigate to the next field, you have the following behaviour:
if the old value is 'Italy' and the entered value is 'France' after the code in the fieldEditorExit that resets old value to 'Italy' the log 'Edit value is ' shows 'France', and not 'Italy'.
In field's editorExit we want to reset the old value, due to an application use case that interacts with server (to simulate that we use a timer);
For your help we have noticed:
- if you remove timer from fieldEditorExit the log shows the correct value ('Italy');
- override method canEditCell and call to method getEditedRecord inside this method produce the issue;
- override method canEditCell without call the method getEditedRecord inside canEditCell it doesn't produce the issue (also with the timer).
How can I override the canEditCell method calling also the getEditedRecord method and reset value on the fieldEditorExit?
We upgraded our application from 4.0p (NIGHTLY 2014-02-12) to 5.0p (NIGHTLY-2015-04-15) and we have an issue with reset old value on a field.
If you run the example and you edit field "Country" and press tab to navigate to the next field, you have the following behaviour:
if the old value is 'Italy' and the entered value is 'France' after the code in the fieldEditorExit that resets old value to 'Italy' the log 'Edit value is ' shows 'France', and not 'Italy'.
In field's editorExit we want to reset the old value, due to an application use case that interacts with server (to simulate that we use a timer);
Code:
public void onModuleLoad() {
CustomListGrid listGrid = new CustomListGrid();
listGrid.setID("simpleListGrid");
listGrid.setWidth(500);
listGrid.setHeight(224);
listGrid.setAutoFetchData(true);
listGrid.setData(CountryData.getRecords());
listGrid.setSelectionType(SelectionStyle.SINGLE);
listGrid.setEditEvent(ListGridEditEvent.CLICK);
listGrid.setAutoSaveEdits(false);
listGrid.setCanEdit(true);
listGrid.setFields(getFields());
listGrid.draw();
}
private ListGridField[] getFields() {
ListGridField countryCodeField = new ListGridField("countryCode", "Flag", 40);
countryCodeField.setAlign(Alignment.CENTER);
countryCodeField.setType(ListGridFieldType.IMAGE);
countryCodeField.setImageURLPrefix("flags/16/");
countryCodeField.setImageURLSuffix(".png");
countryCodeField.setCanEdit(false);
countryCodeField.setFrozen(true);
ListGridField nameField = new ListGridField("countryName", "Country");
nameField.addEditorExitHandler(new EditorExitHandler() {
@Override
public void onEditorExit(final EditorExitEvent event) {
Timer timer = new Timer() {
@Override
public void run() {
String field = "countryName";
int recordIndex = event.getRowNum();
ListGrid grid = event.getGrid();
ListGridRecord record = grid.getRecord(recordIndex);
String value = record.getAttributeAsString(field);
GWT.log("Restore old value is " + value);
grid.setEditValue(recordIndex, field, value);
GWT.log("Edit value is " + grid.getEditValues(recordIndex).get(field));
}
};
timer.schedule(500);
}
});
ListGridField continentField = new ListGridField("continent", "Continent");
ListGridField memberG8Field = new ListGridField("member_g8", "Member G8");
ListGridField populationField = new ListGridField("population", "Population");
populationField.setType(ListGridFieldType.INTEGER);
ListGridField independenceField = new ListGridField("independence", "Independence");
return new ListGridField[]{countryCodeField, nameField, continentField, memberG8Field, populationField, independenceField};
}
private class CustomListGrid extends ListGrid {
/**
* {@inheritDoc}
*/
@Override
public boolean canEditCell(int rowNum, int colNum) {
Record editedRecord = getEditedRecord(rowNum);
String attributeAsString = editedRecord.getAttributeAsString("country");
GWT.log(attributeAsString);
return true;
}
}- if you remove timer from fieldEditorExit the log shows the correct value ('Italy');
- override method canEditCell and call to method getEditedRecord inside this method produce the issue;
- override method canEditCell without call the method getEditedRecord inside canEditCell it doesn't produce the issue (also with the timer).
How can I override the canEditCell method calling also the getEditedRecord method and reset value on the fieldEditorExit?