Datatable Cell Editor displays despite onBeforeCellEditShow originalEvent.preventDefault() being used

UI Components for React
Post Reply
sanfordandrew
Posts: 4
Joined: 15 Jan 2021, 20:03

22 Jul 2023, 15:13

The API for DataTable, Column describes the callback onBeforeCellEditShow. The API description of onBeforeCellEditShow says "Callback to invoke before the cell editor is shown. To prevent editor from showing return false or originalEvent.preventDefault()"

In my code, I invoke originalEvent.preventDefault(). But the editor shows anyway.

Code: Select all

 //  Prevent user from editing mandatory rows
  const onBeforeCellEditShow = (e) => {
    let { rowData, newValue, field, originalEvent } = e;
    if (rowData["mandatory"] == true) {
      originalEvent.preventDefault();

      toast.current.show({
        severity: "info",
        summary: "Can't Edit Mandatory Appointment Fields",
        detail:
          "Only the Description can be Changed on Mandatory Appointment Fields Required by Dockhub",
        life: 6000,
      });
       
    }
  };

Here's a video showing that onBeforeCellEdit is indeed called (the toast shows), but the editor shows despite the originalEvent.preventDefault() running.

https://share.vidyard.com/watch/6J3GPbfSdnEVkwDzfaCSNT?

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

28 Jul 2023, 19:20

I would open a gitHub issue.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest