8 Replies Latest reply: Mar 7, 2014 3:04 PM by jrimblas RSS

    Maintain the state of a collapsible region.

    Gabriel Guzman

      Hi,

       

      I have a Jquery Mobile app with some reports inside collapsible regions. Those reports have a pagination of three rows per page, and when I press the "Next" link it works fine, showing the next three rows. The only problem is that it reloads the page and the collapsible region returns to the default state (closed).

       

      I want to know if there is any way to save the state of the region and load it after the page has reloaded, so the user don´t have to expand it again. I tried with some JavaScript code I found, but it didn't worked.

       

      I'm using Apex 4.2.0.

       

      Thanks in advance.

        • 1. Re: Maintain the state of a collapsible region.
          Gabriel Guzman

          After some experiments, I advanced a little. I save the regions IDs with this:

           

          var lOpenRegions = []

          $(".ui-collapsible:not(.ui-collapsible-collapsed)").each(function()

            { lOpenRegions.push($(this).attr("id")) });

          SetCookie("HideShowOpenRegions",lOpenRegions.join(","));

           

          And I check at the Page Load with this in a DA:

           

          if (GetCookie("HideShowOpenRegions")) {

            $.each( GetCookie("HideShowOpenRegions").split(','),

                      function(intIndex, objValue) {

                        $("#"+$nvl(objValue,"x")).trigger('expand');

                      }

            );

          }

           

          That works whenever I move between the app pages, expanding the regions stored in the cookie, but it doesn't work with the pagination. When I press the Next or Previous links, it checks for the cookie and reads the objValue (tested this with an alert(objValue)) but the regions remains closed.

           

          Someone knows why?

          • 2. Re: Maintain the state of a collapsible region.
            jrimblas

            On Next and Previous the report should issue an apexafterrefresh event that you can use. You'll find it under Framework Events as (After Refresh). I think you'll want to that event to trigger your code.  If you set it to also run on Page Load you shouldn't need two unique DA, just one on the event that fires on page load.

             

            Also, I think the timing of when you save the region IDs could be wrong.  I would add a Click event on .ui-collapsible to save the cookie.  This way everytime a user clicks on them I capture the latest state.

             

            Thanks

            -Jorge

            • 3. Re: Maintain the state of a collapsible region.
              Gabriel Guzman

              jrimblas escribió:

               

              On Next and Previous the report should issue an apexafterrefresh event that you can use. You'll find it under Framework Events as (After Refresh). I think you'll want to that event to trigger your code.  If you set it to also run on Page Load you shouldn't need two unique DA, just one on the event that fires on page load.

               

              That works with Classic Reports too? I tried with the After Refresh event before and it didn't worked.

               

               

              Also, I think the timing of when you save the region IDs could be wrong.  I would add a Click event on .ui-collapsible to save the cookie.  This way everytime a user clicks on them I capture the latest state.

               

              The cookie is fine, with the correct values stored. Nevertheless, your suggestion of firing the DA with the click action is great, because it works with all the regions with that class.

              • 4. Re: Maintain the state of a collapsible region.
                jrimblas

                Hola Gabriel,

                Yes, it works specially well with Classic Reports.  Just make sure the "Enable Partial Page Refresh" option is set to Yes, otherwise there are no events.

                 

                Thanks

                -Jorge

                • 5. Re: Maintain the state of a collapsible region.
                  Gabriel Guzman

                  jrimblas escribió:

                   

                  Hola Gabriel,

                  Yes, it works specially well with Classic Reports.  Just make sure the "Enable Partial Page Refresh" option is set to Yes, otherwise there are no events.

                   

                  Thanks

                  -Jorge

                   

                  I can see the Enable PPR option in the Reports Attributes for Desktop reports, but I'm using Jquery Mobile and I don't see the option in the reports for that kind of interface. The option is not possible with mobile apps?

                  • 6. Re: Maintain the state of a collapsible region.
                    jrimblas

                    I don't see why it wouldn't be the default behavior, but I'll have to look into it.

                    You wouldn't happen to have a sample setup in apex.oracle.com would you?

                     

                    Thanks

                    -Jorge

                    • 7. Re: Maintain the state of a collapsible region.
                      Gabriel Guzman

                      jrimblas escribió:

                       

                      I don't see why it wouldn't be the default behavior, but I'll have to look into it.

                      You wouldn't happen to have a sample setup in apex.oracle.com would you?

                       

                      Thanks

                      -Jorge

                       

                      Sadly, I don't have it, and recreating it is a bit troublesome, because we are working directly in a development enviroment for a client.

                      • 8. Re: Maintain the state of a collapsible region.
                        jrimblas

                        Gabriel,

                        You don't have to recreate your full application.  Just one page, with the report in question and using data from the EMP & DEPT tables. Or any data made up.  Does that make sense?

                         

                        Thanks

                        Jorge