6 Replies Latest reply on Mar 21, 2017 1:51 PM by Eve-Oracle

    Interactive grid event when flipping to single row view

    Eve-Oracle

      Hi

       

      I have a master-detail IG page and I'd like to show the detail grid only when the master is in SRV.

      I figured how to hide the detail grid upon changing from SRV to Report View (I changed the close-single-row-view action adding a call to a dynamic action).

      However I am not finding it easy to change the single-row-view action. If this is the path I should follow I can explain what my challenge is.

      However, I was thinking perhaps there is an event triggering when opening SRV. I am not able to find it though, so appreciating any pointers.

       

      This one looked most promising to me:

           apex.region("emp").widget().interactiveGrid("getViews","grid").singleRowView$.onshow

      But it did not seem to fire when I choose "Single Row View" from the row actions menu.

       

      Appreciating some expert help

       

      thanks so much

      Evelina

        • 1. Re: Interactive grid event when flipping to single row view
          John Snyders-Oracle

          Hi Evelina,

           

          There is a interactivegridviewchange event but that won't help you because it is only fired for changing views such as from chart to icon or icon to grid. Single row and grid are two different modes of the same view; grid view. That is why single row view isn't a button on the toolbar like the other views.

           

          So replacing the action functions to open and close SRV is a reasonable thing to try. Normally all creating or modifying of actions is done in the initActions function set in the Advanced JavaScript code function. However the close-single-row-view action doesn't exist until the grid view is created. So if you are sure that the grid view will be the only view then you can simply add the following code to the page attribute Execute when Page Loads. If the grid view may not be the current view when the page loads then it gets a bit more complicated. Better to wait until 5.1.1 to solve that part of the puzzle.

           

          var originalCloseSRVaction, originalOpenSRVaction,

              ig$ = apex.region("master_ig").widget(),

              actions = ig$.interactiveGrid("getActions");

              closeSRV = actions.lookup("close-single-row-view"),

              openSRV = actions.lookup("single-row-view");

           

          if ( closeSRV && openSRV ) {

              originalCloseSRVaction = closeSRV.action;

              originalOpenSRVaction = openSRV.action;

              closeSRV.action = function(event, el) {

                  originalCloseSRVaction(event, el);

                  console.log("xxx do something now that view is in grid mode");

              };

              openSRV.action = function(event, el) {

                  originalOpenSRVaction(event, el);

                  console.log("xxx do something now that view is in SRV mode");

              };

          }

           

          So whatever you want to do when entering or leaving SRV just put in place of or just after the console.log statements above. Don't bother with a dynamic action at this point. If you want to show or hide a region use the apex.item API. It is strange but that is currently what we use to show and hide both items and regions. Perhaps someday show and hide will be methods of the apex.region() object.

           

          apex.item("detail_ig").hide();

          apex.item("detail_ig").show();

          Same as

          $x_Hide("detail_ig");

          $x_Side("detail_ig");

           

          Regards,

          -John

          1 person found this helpful
          • 2. Re: Interactive grid event when flipping to single row view
            Eve-Oracle

            Hi John,

             

            Again, thanks so much for the elegant suggestion and the helpful comments!

            I am not worried about the grid view not being the currently active as in my page no other view makes sense.

             

            Your solution of course works like charm.

            And it is even very close to my original idea, but I was somehow stuck at the moment where I was trying to replace the original action and the first step in the new action was actionsContext.invoke("single-row-view"); - which was basically calling itself, and not so surprisingly it fell into an infinite loop.

            I then tried to add a custom action to use instead of the original Single Row View - it simply invoked the original action and then showed the detail grid. But then of course I didn't want both the custom and the original actions showing up in the Row Actions menu. When I hid the original Single Row View action calling its hide method, from that point on the custom action wouldn't work either.

            Is this intentional? I mean, I only hid the action, I did not disable it, and still when I was trying to invoke it "manually" it would not work just as it was disabled.. -- this is more out of curiosity ..

             

            One more question, again curiosity - is apex.item performing better than a dynamic action, or what is the reason it is a more recommended way to show/hide the region?

             

            thanks so much!

            Evelina

            • 3. Re: Interactive grid event when flipping to single row view
              John Snyders-Oracle

              Eve-Oracle wrote:

               

              Is this intentional? I mean, I only hid the action, I did not disable it, and still when I was trying to invoke it "manually" it would not work just as it was disabled.. -- this is more out of curiosity ..

               

              It is intentional that an action that is hidden cannot be invoked by any means. An action that is disabled is seen in a disabled state and cannot be invoked by any means. If you want the action to work but hide the UI you would have to hide or remove any UI elements (toolbar buttons, menu items, action buttons etc) that use it.

               

              Regards,
              -John

              1 person found this helpful
              • 5. Re: Interactive grid event when flipping to single row view
                John Snyders-Oracle

                Eve-Oracle wrote:

                 

                One more question, again curiosity - is apex.item performing better than a dynamic action, or what is the reason it is a more recommended way to show/hide the region?

                The issue is not so much about performance. You cannot call from JavaScript code into a dynamic action. They don't work that way. A dynamic action is for responding to some event. So if, from some JavaScript code you want to do something in a dynamic action then you need to make up your own event, trigger it, and have the DA handle that event. That is a lot of work just to use the Show or Hide action. Much easier to just do the hide and show with JavaScript.

                So it is not that apex.item().show/hide is faster than the DA actions Show/Hide (The implementation of DA actions Show and Hide actually use apex.item), it is all the overhead of triggering and responding to an event that really isn't needed.

                Regards,

                -John

                1 person found this helpful
                • 6. Re: Interactive grid event when flipping to single row view
                  Eve-Oracle

                  Explanation much appreciated

                  I had already gone and created the DAs and triggered them as custom events, but if the DAs are themselves using apex.item then I can fully understand it is completely unreasonable to add this extra complexity