We are using SmartGWT 12, updated version.
Change of a field in the grid (Int Field in the example) will trigger an EditorExit event, change of the Boolean Field will not.
The only way to intercept the change of the Boolean Field is with an ClickHandler but that gives plenty of "false positive" since the event is triggered by ANY click on the grid.
Is there a reliable way to have an event for changes on the boolean field?
Change of a field in the grid (Int Field in the example) will trigger an EditorExit event, change of the Boolean Field will not.
The only way to intercept the change of the Boolean Field is with an ClickHandler but that gives plenty of "false positive" since the event is triggered by ANY click on the grid.
Is there a reliable way to have an event for changes on the boolean field?
Code:
private static final ListGridRecord[] RECORDS = { mkRecord(1, true), mkRecord(0, false), mkRecord(2, true), mkRecord(4, false) }; @Override public void onModuleLoad() { VLayout layout = new VLayout(); RootPanel.get().add(layout); DataSource dataSource = new DataSource(); dataSource.setClientOnly(true); dataSource.setTestData(RECORDS); DataSourceField sequenceField = new DataSourceSequenceField("id", "ID"); sequenceField.setPrimaryKey(true); sequenceField.setRequired(true); DataSourceField textField = new DataSourceBooleanField("boolField", "Boolean Field"); DataSourceField intField = new DataSourceIntegerField("intField", "Int Field"); dataSource.setFields(sequenceField, textField, intField); ListGrid listGrid = new ListGrid(dataSource); listGrid.setSize("500", "200"); listGrid.setCanEdit(true); listGrid.setAutoFetchData(true); listGrid.setAutoSaveEdits(false); listGrid.setEditByCell(true); layout.addMember(listGrid); Button button = new Button("Check Modified Records #"); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { GWT.log("Modified Records: " + Integer.toString(listGrid.getAllEditRows().length)); } }); layout.addMember(button); listGrid.addEditorExitHandler(new EditorExitHandler() { @Override public void onEditorExit(EditorExitEvent event) { GWT.log("Modified Records: " + Integer.toString(listGrid.getAllEditRows().length)); } }); listGrid.addCellClickHandler(h -> GWT.log("cellclick")); } private static final ListGridRecord mkRecord(int id, boolean boolField) { final ListGridRecord record = new ListGridRecord(); record.setAttribute("id", id); record.setAttribute("boolField", boolField); record.setAttribute("intField", id); return record; }
Comment