canUndoEdits

Description

Fires when the user tries to undo edits to the List Detail View form. If function returns false, action is cancelled.

When you create a List Control Detail View you can add a number of pre-defined buttons to the UX component that will automatically work with the Detail View and also Synchronize the Detail View with the List Control. The 'Undo', aka 'Reset', button is one of these defined controls.

images/undo.png

Adding a canUndoEdits event definition lets you add some javascript action before the user chooses to cancel the undo. By default, the built in dialog below will appear in the application after the Undo button is pressed. The canUndoEdits event fires before this dialog appears. For example, if a simple alert such as alert("Warning"); is defined for the canUndoEdits Event, then in Live Preview this alert will fire first...

images/undo11.png

...and then be followed by this:

images/undo4.png
This warning is defined in the Customization section of the List Builder's Detail View pane in the "Warning - confirm Detail View form reset" setting.

Adding an Undo Button

To add an Undo button, click on the "List-Detail View-Buttons" option in the Defined Controls section of the UX Controls page. Highlight the list that the Detail View buttons apply to, and check the "Undo edits to Detail View (before edits are saved)" option.

  1. Open the Defined Controls menu and select "List-Detail View-Buttons"

    images/undo3.png
  2. Select a list and the "Undo edits to Detail View (before edits are saved)" option.

    images/undo2.png

Defining canUndoEdits

  1. Define a List with a Detail View like the one in the Creating a Detail View with a Dirty Control Class guide on the "Dirty control class name" page.

    images/undo5.png
  2. Add an Undo button to the component (see above). Define the list control to connect to and the Undo edits to Detail View option.

    images/undo6.png
  3. Highlight the List control. Click the 'List properties' property to open the List Builder.

    images/undo7.png
  4. On the 'Detail View' pane click the [...] button next to the 'Events' property in the 'Client-side Events' section.

    images/undo8.png
  5. Highlight the canUndoEdits event. Add a simple alert to the event in the Javascript code section.

    alert("Undo Warning!");
    images/undo9.png
  6. Click OK and OK. Run the component in Live Preview. Highlight a row in the list control and then make an edit in the detail view. The Reset button should become active.

    images/undo10.png
  7. Click the Reset button. The javascript alert you defined will appear. Click OK

    images/undo11.png
  8. The default Undo Warning will appear.

    images/undo12.png

See Also