Hi,
I tried to use the method setFieldError in a ListGrid, but it seems not to work like I expected.
I wrote a small test:
I thought an error would appear after editing a cell - but it doesn't. What's my mistake?
I know, I could write a CustomValidator. But as far as I don't want to do validation on a single cell, I'd like to use the setError-API.
Thanks & best regards
Thilo
I tried to use the method setFieldError in a ListGrid, but it seems not to work like I expected.
I wrote a small test:
Code:
public class TestGrid extends ListGrid {
public TestGrid() {
setWidth(500);
setHeight(300);
setLeft(200);
setTop(200);
ListGridField field1 = new ListGridField("field1", "Field 1");
field1.setType(ListGridFieldType.TEXT);
field1.setCanEdit(true);
ListGridField field2 = new ListGridField("field2", "Field 2");
field2.setType(ListGridFieldType.TEXT);
field2.setCanEdit(true);
setFields(field1, field2);
setEditByCell(false);
setEditEvent(ListGridEditEvent.DOUBLECLICK);
ListGridRecord[] r = new ListGridRecord[2];
r[0] = new ListGridRecord();
r[0].setAttribute("field1", "a");
r[0].setAttribute("field2", "b");
r[1] = new ListGridRecord();
r[1].setAttribute("field1", "c");
r[1].setAttribute("field2", "d");
setData(r);
addEditorExitHandler(new EditorExitHandler() {
public void onEditorExit(EditorExitEvent event) {
setFieldError(event.getRowNum(), "field1", "my error");
validateCell(event.getRowNum(), "field1");
}
});
}
}
I know, I could write a CustomValidator. But as far as I don't want to do validation on a single cell, I'd like to use the setError-API.
Thanks & best regards
Thilo
Comment