Announcement

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

    Button states (enable/disable) depending on grid state

    Environment
    SmartGWT version 3.1p - commercial
    Browser: Firefox from 10 to 20

    I have MainWidget (e.g. ListGrid) which can have child widgets, such as: combo boxes, checkboxes etc. There are also buttons (outside MainWidget): "save" and "cancel". Save - sends data from MainWidget to server, cancel - reloads data from server to MainWidget.
    In application I need to disable/enable button:

    When MainWidget is loaded or reloaded (initial state). Then buttons should be disabled.

    After any change commited to MainWidget or any of its child widgets - buttons should be enabled. But:

    After changes - when MainWidget will get back to its initial state - buttons should be disabled.

    Important thing is that it must be universal solution. How can we achieve it?

    #2
    There isn't something like a magic event that fires in all 3 of these circumstances.

    DataChanged on the ResultSet automatically created by a ListGrid could be used to evaluate whether there are outstanding changes whenever data is saved which affects the Records the grid is showing. This will not fire at component creation so you will need to separately handle that case.

    ListGrid.hasChanges() tells you whether the grid is tracking changes, and DynamicForm.valuesHaveChanged() provides the same information for forms.

    Comment

    Working...
    X