Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    BUG REPORT: Change of Boolean Field in List Grid does not trigger event

    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?

    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;
    }

    #2
    See listGridField.canToggle: the default for a editable boolean field is to allow the value to be toggled without triggering the editor per se (eg, rendering editors for all other editable columns as well, when editing by row).

    For this reason editorExit in particular would not be expected to fire. But the change() and changed() notifications do fire as usual, as well as all other notifications of an actual change (editorExit is not a change notification).

    Comment


      #3
      That works, thank you

      Comment

      Working...
      X