FlexGrid confirm to delete row, confirm to add row

Posted by: adobozi on 10 September 2025, 7:38 pm EST

    • Post Options:
    • Link

    Posted 10 September 2025, 7:38 pm EST

    Is there a way to get user confirmation to delete a row or add a new row similar to the way the FlexGridExplorer EditConfirmation confirms individual cell edits?

    I.e. I want to prompt the user “Are you sure you want to delete this row?” and “Are you sure you want to add a row?”

  • Posted 11 September 2025, 9:29 am EST

    Hi Attila,

    To prompt the user for confirmation when they press the Delete key to delete a row, you can override the OnKeyDown method of the GridCellFactory, cancel the default delete operation, display an alert for user confirmation, and then manually delete the row. We have attached a sample project demonstrating this implementation.

    Regarding confirmation for adding a new row, we are not entirely clear about your requirement. Are you using the NewRowPosition property to display an empty row that users can edit to add new data? If so, do you want to show an alert when the user starts editing this row and then moves focus to another row, thereby confirming the addition? Please share the exact details so we can investigate accordingly.

    Attachment: AddDeleteConfirmation.zip

    Best Regards,

    Kartik

  • Posted 11 September 2025, 11:34 am EST

    Re: adding new row. I’m using the NewRowPosition=Bottom. My requirement is that before the user adds add a row that all current data is valid. If there are any errors then show a message “Please fix errors before adding row.” and abort the add. If using the NewRowPosition can’t accomplish that then I’m open to other solutions.

  • Posted 12 September 2025, 5:16 am EST

    Hi Attila,

    As per our understanding of your requirement, whenever the user edits the new row and tries to commit it, but the row contains an invalid value in one of the columns, you want to alert the user that the value is invalid and prevent them from adding this row until the invalid value is fixed.

    The best approach for this is to handle the RowEditEnding event of the FlexGrid, and cancel the edit if a value is invalid.

    Please refer to the updated sample project, where leaving the FirstName column empty for the new row triggers an alert and prevents the new row from being added. After the user clicks OK on the alert, they can either enter a valid value for the FirstName column or press the Escape key to cancel the new row entirely.

    Attachment: AddDeleteConfirmation_Updated.zip

    Best Regards,

    Kartik

  • Posted 12 September 2025, 11:33 am EST

    Hello Kartik,

    Your sample code clearly shows how to work with the new row but it’s not what I’m looking for.

    I don’t need to validate the new row after the user edits it. I need to validate all existing rows before allowing the user to tap on, or down arrow to the new row. When the user attempts to focus on the new row I want to display a message if there are errors and stop the new row from gaining focus.

    Maybe the best way to do this is without using the NewRowPosition. I can detect the down arrow keypress on the last grid row, validate the existing rows, then if the data is invalid show the message else add a row to the grid in code.

  • Posted 15 September 2025, 4:58 am EST

    Hi Attila,

    Yes, this would be the best approach for your use case. When the navigation keys are pressed, you can check if the selected/cursor row is currently the last row (when NewRowPosition=None) or the second-last row (when NewRowPosition=Bottom) and then show the message to the user in case the data in any existing row in invalid.

    Best Regards,

    Kartik

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels