Announcement

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

    ListGrid.clearEditValue() oddness

    We have a ListGrid backed by a DB. Updates are done manually (clicking a button calls updateAll()). That is, we have

    setAutoSaveEdits(false);
    setModalEditing(false);

    and pending changes are not persisted unless and until updateAll() is called.

    Within each row there is a checkbox used to control the editability of the other cells in the row. Toggling this "Editable" checkbox controls the editability of cells via an overriden canEditCell() method. So it looks something like this:

    Editable Value 1 Value 2
    [ ] ____ ____
    [ ] ____ ____
    [ ] ____ ____
    ...

    When the user un-checks "Editable", we revert any pending changes by calling clearEditValues(). This succeeds in clearing/reverting pending changes made in any single row. However, if there are pending changes in another row, and the user un-checks the "Editable" checkbox in that other row, those changes do not get cleared.

    Perhaps even odder is that, if you re-check and then un-check "Editable" in the other row, the pending changes ARE in fact cleared. It's as if it didn't get the idea the first time around...

    The onChanged() method for the "Editable" field looks like this:

    @Override
    public void onChanged(ChangedEvent event) {
    FormItem formItem = event.getItem();
    int row = event.getRowNum();
    boolean isChecked = Boolean.valueOf(formItem.getValue().toString());
    if (!isChecked) {
    Map rowValues = getEditValues( row );
    Set keys = rowValues.keySet();
    keys.remove( COL_EDITABLE ); // don't revert Editable checkbox
    for (Object key : keys)
    clearEditValue(row, (String) key); // revert to saved value
    }
    refreshRow(row);
    }
    Last edited by rknights; 21 Jul 2010, 13:27.

    #2
    Try discardAllEdits()

    Comment

    Working...
    X