FeatureTable v4.26 - Show confirmation prompt for data edits/updates

476
2
05-13-2023 05:54 AM
Ranga_Tolapi
Occasional Contributor III

How to show confirmation prompt for data edits/updates in FeatureTable?

0 Kudos
2 Replies
RachelGomez
New Contributor II

To show a confirmation prompt for data edits or updates in a FeatureTable, you can use the beforeApplyEdits event and the window.confirm() method. Here's an example of how you can achieve this:

javascript
Copy code
// Assuming you have a FeatureTable instance called 'featureTable'
featureTable.on("beforeApplyEdits", function (event) {
var confirmMessage = "Are you sure you want to apply the edits?";
var confirmed = window.confirm(confirmMessage);

if (!confirmed) {
event.preventDefault(); // Prevent the edits from being applied
}
});
In the above code, the beforeApplyEdits event is triggered before the edits are applied to the feature table. Inside the event handler, a confirmation prompt is shown using window.confirm(), displaying the message "Are you sure you want to apply the edits?". If the user confirms the action, the edits will be applied as usual. If the user cancels or chooses not to proceed, the event.preventDefault() method is called to prevent the edits from being applied.

By implementing this code, you can show a confirmation prompt to the user before applying any edits or updates in the FeatureTable.

Regards,

Rachel Gomez

0 Kudos
Ranga_Tolapi
Occasional Contributor III

Hi, @RachelGomez thank you for the response. I do not see "beforeApplyEdits" event applicable to FeatureTable in version 4.x?

0 Kudos