10 Replies Latest reply: Aug 21, 2013 2:38 AM by Tom Petrus RSS

    Calling jQuery between Interactive Report pagination

    725237
      Hi,

      I'm using jQuery to manipulate an Interactive Report (reformat it to behave as a nested/floating table so that the report headers stay put while the data scrolls within a div) namely by adding the required HTML tags in certain places.

      In any case, I have the crux of the matter sorted out, except the code breaks when moving between results through pagination.

      I can understand that this is a result of the AJAX call being made to replace the table with new data. In this situation, the jQuery code is obviously not being re-fired and thus the next set of results that load revert back to the original interactive report format.

      My question is to find the appropriate jQuery/AJAX syntax that can listen or bind to the pagination AJAX call. I am not familiar with AJAX but have been able to use the following code to test whether jQuery could pick up on AJAX calls at all, testing for all events.
      $.ajax({
           ajaxStart : function(){
                console.log("hello 1");
           },
           beforeSend: function(){
                console.log("hello 2");
           },
           ajaxSend : function(){
                console.log("hello 3");
           },
           success : function(){
                console.log("hello 4");
           },
           ajaxSuccess : function(){
                console.log("hello 5");
           },
           error : function(){
                console.log("hello 6");
           },
           ajaxError : function(){
                console.log("hello 7");
           },
           complete : function(){
                console.log("hello 8");
           },
           ajaxComplete : function(){
                console.log("hello 9");
           },
           ajaxStop : function(){
                console.log("hello 10");
           }
      });
      It returned for beforeSend, success and complete for the initial page load, but did not respond to subsequent ajax events (e.g., when paginating to a new set of rows). I speculate that this is due to the nature of the AJAX call. jQuery responded to a GET method used on page load, but not a POST method used for pagination.

      I hope this is enough direction for community members with knowledge to assist. Any help provided would be greatly appreciated.
        • 1. Re: Calling jQuery between Interactive Report pagination
          Tyler-Oracle
          The long term solution to this is for the APEX team to add jQuery "Events" to Interactive Reports so we can bind functions to those events. I'm about 99% sure they're doing this for 4.0. Short term, 1 solution is to add a transparent image as a column in your report with an "onload" event. So, your columns might be "NAME", "EMAIL", and "TRANSPARENT_IMAGE". When that image is loaded, you can use jQuery selectors to walk up to the row ( $(this).closest('tr') ) and apply your code.

          Someone else might have a better solution, so you might give this a few minutes before you implement my suggestion...

          Tyler Muth
          http://tylermuth.wordpress.com
          [Applied Oracle Security: Developing Secure Database and Middleware Environments|http://sn.im/aos.book]
          • 2. Re: Calling jQuery between Interactive Report pagination
            708185
            Hi,

            I would add a 'live' onclick event on the pagination images. Look at the livequery plug-in if you did not upgrade to the latest jQuery version.

            It should look like something like : jQuery("#imgId").livequery("click", function() { ... } )

            Karl

            Edited by: KarlGuillotte on 8 déc. 2009 19:52
            • 3. Re: Calling jQuery between Interactive Report pagination
              725237
              Thank you Tyler and Karl for your responses.

              Karl: tried your method to add the live onclick event. Didn't seem to respond to this function however. I'm using the latest stable release 1-3-2 i believe.
              • 4. Re: Calling jQuery between Interactive Report pagination
                jariola
                Hi,

                Try something like below
                <script>
                $(function(){
                  $('span.fielddata a img').live('click', function(){
                    alert('Pagination');
                    // Your actions here
                  });
                });
                </script>
                • 5. Re: Calling jQuery between Interactive Report pagination
                  725237
                  Thanks Jarola! You've put me in the right direction.

                  Unfortuantely, it looks like the function I called within the block you wrote executed BEFORE the AJAX pagination occured. Is there any foreseeable way to have jquery wait or delay for an event (e.g., ajax response)?
                  • 6. Re: Calling jQuery between Interactive Report pagination
                    jariola
                    Hi,


                    I think at least one way is use jQuery and attach your function end of a tag herf. I have not tested this.

                    Pagination a tag href is something like this
                    javascript:gReport.navigate.paginate('pgR_min_row=11max_rows=5rows_fetched=5')
                    So you could manipulate it with jQuery to be like
                    javascript:gReport.navigate.paginate('pgR_min_row=11max_rows=5rows_fetched=5');yourfunction();
                    Then it first call pagination and after it is ready your function.

                    As I did say , need also check and test

                    br, Jari
                    • 7. Re: Calling jQuery between Interactive Report pagination
                      725237
                      Jarola,

                      Yeah I tried this method previously, but it resulted in the same effect.

                      The function called DOES in fact run when clicked, but this is too early.

                      I need the function to be executed when post-AJAX-pagination. I can see the table manipulations happen for half a second, and then the AJAX kicks in and replaces the entire body with the new code pulled in.


                      Hope this provides some better context. I tried using a ajax complete listen but it doesn't seem to be able to trigger based on that event. I suspect it could be the usage of GET vs. POST for the AJAX call being made.
                      • 8. Re: Calling jQuery between Interactive Report pagination
                        jariola
                        Hi,

                        Ok, I have not tested that with interactive report.

                        Whit classic report PPR pagination that trick works ok at least in Firefox =). I have not tested IE
                        http://apex6.revion.com/pls/apex/f?p=196:24

                        In example I have attach function that make again "fixed table" after pagination

                        Br, Jari
                        • 9. Re: Calling jQuery between Interactive Report pagination
                          7d216c91-5df1-4e28-ab46-4b586e060caf

                          Hi,

                           

                          I have the same problem with classic report.

                          jariola, how can i find out login/password for your app?

                           

                          Thx.

                          • 10. Re: Calling jQuery between Interactive Report pagination
                            Tom Petrus

                            why do you need to revive a thread from december 2009 which actually is applicable on apex 3.2 ? So much has changed since then. Your problem isn't clear to anyone not involved with this since a lot of the issues and examples are plain out of date. And while Jari is still an active poster around here, the other posters on this thread aren't. Noone has watches on it anymore. The question was never set to resolved and the op has not even reacted on Jari's last suggestion.

                             

                            You should simply create a new thread, state your problem clearly, and perhaps provide a link to this old thread as a reference. That gives you a much broader audience and a better chance to get your issue fixed. And on top of that, it gives the people who voluntarily help you out a chance to earn some points, which while being esoteric to some are always a nice gesture anyway. Having a resolved question will also much better help out other users stumbling on it. Give and take.