5 Replies Latest reply: Mar 26, 2014 11:32 AM by Nicolette RSS

    popupkey_from_lov yet another issue

    user10977496

      I have a updatable report generated with apex_item.popupkey_from_lov function.

      If interested... the reason for updatable report instead on tabular form is that I need multiple updateable reports on one page. The reason for popupkey instead of select list is the large number of records in the LOV

      It works fine, except when there are no records in the report and you add a record, the popup page does not show any values. This happens the first time after login. It works fine after a page refresh while at least one record exists. Just that page refresh is not desirable.

      There are no JS errors on the page. The item is generated correctly (if you look with Firebug) but without the <script> that generally is generates just before the item... is that a hint?

      Anyone seen this before? Solved it?

       

      DB: XE

      APEX version: 4.2.4

      Theme: Responsive with no changes in the POPUP LOV template

        • 1. Re: popupkey_from_lov yet another issue
          Nicolette

          User10977496

           

          user10977496 wrote:

           

          I have a updatable report generated with apex_item.popupkey_from_lov function.

          If interested... the reason for updatable report instead on tabular form is that I need multiple updateable reports on one page. The reason for popupkey instead of select list is the large number of records in the LOV

          It works fine, except when there are no records in the report and you add a record, the popup page does not show any values. This happens the first time after login. It works fine after a page refresh while at least one record exists. Just that page refresh is not desirable.

          Do you mean that only when you enter the page for the first time after login that is the only time there are no records in the report and as such it isn't working?

          Or there are other times that there are no records and in those situation the popkey lov those work on new rows?

           

          A page refresh is not desired but have you tried a refresh of the region?

          How is the new row added? An example on apex.oracle.com would probably explain more and better how you have implemented all the puzzle pieces then a post her could.

           

          When looking at a tabular form created with the wizard the popup function isn't located inside the newly add row but gets the location "jquery-1.7.1.js/eval/seq/2"

          .

          Nicolette

          • 2. Re: popupkey_from_lov yet another issue
            user10977496

            You can reproduce the problem on http://apex.oracle.com/

            workspace WS_MIRELA, username guest, pass Tr4nf3rpa66!, Home page

            Steps to reproduce it:

            1. Log in => See the report with rows => click on Add row => click on the popupkey item => It works

            2. Change the query of the region by adding "and c002 is null" at the end of the query

            3. Log out from the APEX application => Log in (you should not get any records) => click on Add row => click on the popupkey item => Empty  Popup opens

             

            Mirela

            • 3. Re: popupkey_from_lov yet another issue
              Nicolette

              Mirela

               

              The "logout and login" step turns out to be the essential part.

              1. Log in => See the report with rows => click on Add row => click on the popupkey item => It works
              2. Change the query of the region by adding "and c002 is null" at the end of the query
              3. Run the page (you should not get any records) => click on Add row => click on the popupkey item => It works.

               

              The url(of the popup) when it doesn't work and when it does work are the same.

              So I have now idea what is going on.

              But that it works when you don't logout gave me an idea how to work around it.

               

              The idea is to have an empty row when the collection is empty and hide that row with javascript.

               

              The sql of the then becomes

              select apex_item.popupkey_from_lov(1, c002, 'LOV_CUSTOMER'
                       , 50, 100, '0', 'YES', 100, '', 'YES'
                       ) as customer
              ,      apex_item.text(3, c003, 10, 10, '', 'f03_' || lpad(rownum, 4, 0))
                      as ORDER_TOTAL
              from   apex_collections
              where  collection_name = 'ORDER'
              union all
              select apex_item.popupkey_from_lov(1, null, 'LOV_CUSTOMER'
                       , 50, 100, '0', 'YES', 100, 'class="nodata"', 'YES'
                       ,'SS' || lpad(rownum, 4, 0)) as customer
              ,      apex_item.text(3, null, 10, 10, '', 'f03_' || lpad(rownum, 4, 0))
                      as ORDER_TOTAL
              from dual
              where not exists (select '' from   apex_collections where  collection_name = 'ORDER')
              

              The 'class="nodata"' is used to recognize the 1 row when the collection is empty.

               

              The javascript for hiding the empty row and showing a no data found message is.

              remove_first_row = function(){
                var region,data;
                region = $('#report_ORDERS').parent();
                data = region.find('.nodata');
                if(data.length === 1){
                  region.children().hide();
                  region.append('<span class="nodatafound">no data found</span>');
                }
              }
              

              And run the function on page load.

              ORDERS is the static id of the orders region.

               

              I have implemented this on page 3 of your application.

               

              Nicolette

              • 4. Re: popupkey_from_lov yet another issue
                user10977496

                Hallo Nicollette,

                 

                The workaround works up to a level (the .hide should be applied for all the children... so if others want to implement the solutions some extra JS would be necessary). But I find it rather dangerous because it is done with javascript. I will be surprised if everything works on page submit if you have an extra row that you might submit.There should come another workaround.

                Thanks for your help.

                 

                If you have the same problem, another workaround (not tested) would be a custom template where you do not show the first row entirely:

                0. Add the extra empty row. Make sure it is always the first row

                1. Copy the report template (the one you are currently using in the report)

                2. In the new template by

                3. By Column Template 1 nothing (or a space) with as Condition PlSQL expression #ROWNUM#  = 1

                On the page by report template choose the new template. Because it it done with templating the record is not rendered therefore not submitted.

                 

                I think the original issue should be reported as a bug. Or maybe have other people other ideas...

                The above account is locked, so if you want to test ask me for a new password.

                 

                Regards,

                Mirela

                • 5. Re: popupkey_from_lov yet another issue
                  Nicolette

                  Mirela

                   

                  Tabular forms created trough the wizard behave in the following way.

                  The add button adds a row with javascript and only in the html. More rows added is just more rows in the apex_application.g_fXX array's.

                  The row that is added is automatic added when the page is rendered and when the rendering is done javascript that is executed for tabular forms copy's this row in an global js variable and removes it form the DOM.

                   

                  Now what you have to worry about is that you can match the row in the apex_application.g_fXX array's with the corresponding row in your collection. Usually this is done with having the sequence of the collection member also in one of the collection columns and in a hidden item in the report.

                  The added row has no corresponding row in the collection and should be filtered out when you process the apex_application.g_fXX array to put the data (changes) in your collection upon submit. Easily done by giving that special row a sequence of 0 or lower. And add an if construction to your processing process so only row sequence 1 and up are handled .

                   

                  I don't know if you just left it out of your example application. But when you make changes to the data in your tabular form and then add a row all the changes are lost.

                  This is because the changes aren't saved in to the collection before the a new member is added to the collection and the report is refresh getting all the data fresh from the server.

                   

                  As for

                  the .hide should be applied for all the children

                  I don't really understand what you mean. It hides the report part of the region. The exact same part that is replaced upon refresh of the region. So what other children do you mean?

                  Or do you mean other tabular forms on your page like you mentioned having in your original post.

                  If so then consider the following

                  remove_first_row = function(){  
                    var region,data,region_ids; 
                    region_ids = ['ORDERS','PRODUCTS'];
                    for (k=0;k<region_ids.length; k++) {
                      region = $('#report_'+region_ids[k]).parent();  
                     data = region.find('.nodata');  
                      if(data.length === 1){ 
                  region.children().hide();
                        region.append('<span class="nodatafound">no data found</span>');  
                      }
                    }
                  }
                  

                  Added is an array holding all the static ids from the regions involved. And then it loops through all the ids changing the reports if necessary one by one.

                  The above code isn't tested so it could be missing any ' or ) so double check before using it.

                   

                  Nicolette