Hi all,
I'm trying to set an error to a specific field when that field is > than another field in that row. However, for some reason it reverts the value chosen to the older one.
For example:
I have a field myFirstFieldItem with choices of 2, 4, 6 for the user and another field myOtherItem with choices of 2, 4, 6 for the user
If teh user chooses 6 for myFirstFieldItem and 2 for myOtherItem I want an error on myFirstFieldItem to show. I don't, however, want it to revert the change.
Here is my code:
myFirstFieldItem .addChangedHandler(new com.smartgwt.client.widgets.grid.events.ChangedHandler() {
@Override
public void onChanged(com.smartgwt.client.widgets.grid.events.ChangedEvent event) {
int row = event.getRowNum();
Record record = myGrid.getRecord(row);
int myFirstFieldItemIdx =event.getValue();
int myOtherItemValIdx= record.getAttribute("myOtherItem");
if (myFirstFieldItemIdx > myOtherItemValIdx) {
String message = "myFirstFieldItem is greater than myOtherItemValIdx";
myGrid.setFieldError(row, "myFirstFieldItem ", message);
} else {
myGrid.clearFieldError(row, "myFirstFieldItem ");
}
}
});
I also tried it with .addChangeHandler but still got the same thing.
I'm trying to set an error to a specific field when that field is > than another field in that row. However, for some reason it reverts the value chosen to the older one.
For example:
I have a field myFirstFieldItem with choices of 2, 4, 6 for the user and another field myOtherItem with choices of 2, 4, 6 for the user
If teh user chooses 6 for myFirstFieldItem and 2 for myOtherItem I want an error on myFirstFieldItem to show. I don't, however, want it to revert the change.
Here is my code:
myFirstFieldItem .addChangedHandler(new com.smartgwt.client.widgets.grid.events.ChangedHandler() {
@Override
public void onChanged(com.smartgwt.client.widgets.grid.events.ChangedEvent event) {
int row = event.getRowNum();
Record record = myGrid.getRecord(row);
int myFirstFieldItemIdx =event.getValue();
int myOtherItemValIdx= record.getAttribute("myOtherItem");
if (myFirstFieldItemIdx > myOtherItemValIdx) {
String message = "myFirstFieldItem is greater than myOtherItemValIdx";
myGrid.setFieldError(row, "myFirstFieldItem ", message);
} else {
myGrid.clearFieldError(row, "myFirstFieldItem ");
}
}
});
I also tried it with .addChangeHandler but still got the same thing.
Comment