2 Replies Latest reply on Feb 12, 2019 10:57 AM by Oleh Tyshchenko

    APEX 18.2 IG bug: Grid became uneditable after Javascript error

    Oleh Tyshchenko

      Well, maybe not a bug but I think IG might be a bit more reliable. So I have an editable grid and one column of this grid has a dynamic action. The purpose of this dynamic action is to set some value to some other column in this grid. When I change type of this other column to Display Item the DA starts to throw "Uncaught Error: Set value not allowed for field." Javascript error. I consider this as documented behavior, although I don’t like it. But at the same time I noticed that the rest of grid's records became uneditable. And if you press Add row button then new record created but all the columns close from editing. John Snyders-Oracle, Patrick Wolf-Oracle could you have a look what's wrong.

       

      Demo application

        • 1. Re: APEX 18.2 IG bug: Grid became uneditable after Javascript error
          John Snyders-Oracle

          Hi,

          The best way to avoid this is to not have a JavaScript exception. I'm also not sure it is a bug but as you say APEX could be more robust. I can describe what is happening and why edit never works again.

           

          When the value of a cell is going to be updated asynchronously the lockActive method must be called before the async action (for example an ajax request) and unlockActive must be called after. The reason for this is that the edited row must remain locked so that any async updates apply to the correct row. The user can't keep editing a new row until all async edits to the current row are complete. This is all explained in the help for these methods (https://docs.oracle.com/en/database/oracle/application-express/18.2/aexjs/grid.html#lockActive ). This is handled automatically for dynamic actions because the IG region interface supports the getSessionState method and the beforeAsync and afterAsync callbacks. This part of the region interface is not currently documented and you would have to look at the code. But you don't need to know about that just that lockActive and unlockActive are called automatically from the server.js module around the ajax request that is done by the Set Value DA.

           

          If there is an exception or other kind of JavaScript error while processing the async action then unlockActive will never be called. This is why the grid can not be edited after the error.

          You can prove that this is the problem on your demo app by doing this after the error:

          apex.region("R88887452800659125901").call("getCurrentView").view$.grid("unlockActive")

          Then you can edit again.

           

          So it could be that APEX should have a try catch handler somewhere to protect against this. In general APEX library doesn't have a lot of try catch blocks. The general philosophy is that the developer provided code should not have errors or exceptions and if it does it should fail fast at the point of error. The practical reason is that lots of try catch can slow JavaScript down.

           

          Regards,
          -John

          • 2. Re: APEX 18.2 IG bug: Grid became uneditable after Javascript error
            Oleh Tyshchenko

            John, thanks for the comprehensive explanation. Let's agree that the root cause is a bug in my application.

             

            May I also ask you to have a look at example of grid's misbehavior: APEX 18.2 IG bug: Column lose it position after resize and page refresh

             

            In addition I would like to report about a minor issue in master-detail IG. Removing a filter in a master report setting area I get "Uncaught TypeError: Cannot read property '_data' of undefined" error. The error stack looks like this:

            Uncaught TypeError: Cannot read property '_data' of undefined
                at Object._restoreDataState (model.js?v=18.2.0.00.12:3877)
                at Object.onChange (model.js?v=18.2.0.00.12:4911)
                at notifyChange (model.js?v=18.2.0.00.12:234)
                at Object.clearData (model.js?v=18.2.0.00.12:1014)
                at widget.interactiveGrid.js?v=18.2.0.00.12:9368
                at $.(/pls/apex/anonymous function).(anonymous function)._forEachView (https://static.oracle.com/cdn/apex/18.2.0.00.12/libraries/apex/widget.interactiveGrid.js?v=18.2.0.00.12:2898:21)
                at $.(/pls/apex/anonymous function).(anonymous function)._forEachView (https://static.oracle.com/cdn/apex/18.2.0.00.12/libraries/jquery-ui/1.12.0/jquery-ui-apex.js?v=18.2.0.00.12:474:25)
                at Object.success [as callback] (widget.interactiveGrid.js?v=18.2.0.00.12:9366)
                at success (server.js?v=18.2.0.00.12:1465)
                at Object.lOptions.success (server.js?v=18.2.0.00.12:1401)
            

             

            Steps to reproduce:

            Lets assume we have DEPT and EMP grids connected with master-detail relationship when DEPT is a muster. Add a new record to the DEPT region and save the changes. Then add a filter to the DEPT region to return only the record we've just created. Delete this record from the DEPT region and save the changes. Now delete the filter by pressing Remove Filter button in the report setting area. The error should occur in the console.

             

            Demo application