14 Replies Latest reply on Jun 30, 2020 10:25 PM by jacknomiz

    How to I redirect to the row after a deleted row

    PhilMan2

      Hello,

      I'm using Apex 18.1 on an 18.C platform.

      I have an interactive report that sorts clients in ascending order by last name.  When I click on the link, it takes the user to a maintenance page where they can view, modify create or delete the client.  When the user is through the editing process, the maintenance page uses the After Processing / Page or URL (Redirect) to take them back to the interactive report.  That all works well.

      The problem is that it always takes the user to the beginning of the interactive report (Last Name starting with "A").

      How can the user return from the maintenance page to the interactive report near where they left off?  So if they were editing or deleting Ellison, it would return them back to the E's and not the A's in the interactive report?

      Thanks for looking at this.

        • 1. Re: How to I redirect to the row after a deleted row
          jacknomiz

          Hi, there are many ways to achieve this.

          Your calling page (IR) needs to know which item you clicked to edit or which record you added new, and needs to adjust IR display accordingly.

           

          If you want to highlight edited or new record, these links will help:

          https://mk-commi.blogspot.com/2016/01/coloring-cells-in-interactive-report.html

          http://deneskubicek.blogspot.com/2010/07/highlight-row.html

           

          I went through this process couple of years ago, and to me Denes Kubicek method was the best. Works nicely.

          Follow his method and he's got a very useful example page.

           

          I can't remember now if it will do repaginate for you, but will definitely highlight edited record.

           

          Thanks

          Jack

          1 person found this helpful
          • 2. Re: How to I redirect to the row after a deleted row
            PhilMan2

            Thanks for responding Jacknomiz.

            First I tried the first link and copied the application locally.  It works locally like it does on the Apex site https://apex.oracle.com/pls/apex/f?p=83537 .  The problem is that I can't figure out how to highlight the row in the report based on the row that was edited in the corresponding form.  In the case of a Delete activity, when I delete a row in the form, I'd like the report to highlight a row near the row that was just deleted.

            Next, I looked at the Kubicek example.  I made a new Report / Form on the EMP table.  The Report and Form work fine.

            Using Denes Kubicek's instruction page I made three modifications:

            1) In the page HTML Header I added the following:

            <script language="JavaScript" type="text/javascript">

            function highlight_nodes (pthis) {

            if (pthis) {

            for( var i = 0; i

               < pthis.parentNode.parentNode.childNodes.length; i++ )

            pthis.parentNode.parentNode.childNodes[i].style.backgroundColor = '#A7C6DF';}

            }

            </script>

            2) In the HTML Expression of the last column (DEPTNO) I added the following:

            <span id="row_#EMPNO#">#DEPTNO#</span>

            3) In the page Footer Text I added the following:

            <script>

            highlight_nodes(document.getElementById('row_&P5_EMPNO.'));

            </script>

            The only change I made was to the Footer Text field.  I modified 'row_&P151_EMPNO' to 'row_&P5_EMPNO'.  Page 5 is the interactive report and page 6 is the form.

            The Kubicek example showed no highlight at all.  This seems like it was originally written for Apex 4.  Does this still work in Apex 18?

            Thanks for checking.

            • 3. Re: How to I redirect to the row after a deleted row
              jacknomiz

              I made it work in 19.2.

              Please check that you put this code into Header and Footer (header text  / footer text) -  NOT HTML header.

               

              1 person found this helpful
              • 4. Re: How to I redirect to the row after a deleted row
                PhilMan2

                I moved the "Header" script from HTML Header to Header and Footer / Header Text

                The Original Footer Text was OK

                The last column (DEPT_NO) was OK.

                It still doesn't work.

                • 5. Re: How to I redirect to the row after a deleted row
                  jacknomiz

                  Are you assigning your selected record ID to :P5_EMPNO via IR edit link on redirect to edit page AND on the way back?

                  Just display P5_EMPNO to see it's populated please - can you see it?

                  1 person found this helpful
                  • 6. Re: How to I redirect to the row after a deleted row
                    PhilMan2

                    On Page 5 (The report page) the Link Target reads:

                    Name:  P6_ROWID

                    Value: \#ROWID#\

                    The value is displayed (e.g. AAAocaAANAAAC/7AAA)

                    The value of Footer Text was changed to:

                    <script>

                    highlight_nodes(document.getElementById('&row_P5_EMPNO.'));

                    </script>

                     

                    On Page 6 (The form page) the value of P6_ROWID is displayed (after I changed it to Display Only)

                    How do I set the value of RowID for the way back (from 6 to 5)? 

                    Is &row_P5_EMPNO. the right field name for the Footer Text?  The "row_" isn't part of the item name on the form.  On the form the field is: P6_EMPNO

                    • 7. Re: How to I redirect to the row after a deleted row
                      jacknomiz

                      When you go back from page6 to page5, assign value from P6_ROWID to P5_EMPNO in page 6 branching.

                       

                       

                      1 person found this helpful
                      • 8. Re: How to I redirect to the row after a deleted row
                        PhilMan2

                        Thanks for keeping up with this. 

                        On Page 6 Behavior / Target I clicked on the link button labeled Page 5.  I added the following:

                        Name: P5_EMPNO

                        Value: P6_ROWID

                        I tried that.  But I got an error (ERR-1002 Unable to find item ID for item "P5_EMPNO" in application "100").

                        The only thing on page 5 is the Interactive Report.  There's no field called P5_EMPNO.

                        Also, should I be assigning the report EMPNO with the form ROWID?  The values are quite different.

                        • 9. Re: How to I redirect to the row after a deleted row
                          jacknomiz

                          All good, happy to help

                           

                          I would pass PK of your record, not rowid.

                          I assume PK is EMPNO?

                           

                          in page 5 create page item - P5_EMPNO

                          page 5, IR -in  edit link - assign PK (empno?) of currently selected row to P6_EMPNO and call page 6

                           

                          in page 6, when you are branching back to calling page, assign P6_EMPNO to P5_EMPNO

                           

                          rest should be ok, please try.

                           

                           

                          1 person found this helpful
                          • 10. Re: How to I redirect to the row after a deleted row
                            PhilMan2

                            This is all using the sample EMP table that is included with the database install.

                            I tried everything from your request above.  It passes back the EMPNO (which is the primary key of the sample EMP table) from the form on page 6 to single field on page 5.  The value shows up.  But the row is still not highlighted.

                            Is there a way I can get the application to you?  Upload to Apex.com perhaps?  I forget how to do that.

                            • 11. Re: How to I redirect to the row after a deleted row
                              PhilMan2

                              Got it working.  I was trying things on my own and had changed the Footer Text to &row_P6_EMPNO by mistake.  Once I changed it back to &row_P5_EMPNO all worked well.

                              Many Thanks for all your help.  I really appreciate it.

                              • 12. Re: How to I redirect to the row after a deleted row
                                jacknomiz

                                Hey happy to help. This method works nicely cheers.

                                • 13. Re: How to I redirect to the row after a deleted row
                                  PhilMan2

                                  Hello again Jacknomiz.  As I tested this morning (I'm in Boston, MA, USA) I realized that this solution doesn't as yet accommodate the Delete activity.  The report on page 5 is sorted by ENAME (Jones, King, Martin, etc.).  So when the user is on t he report page (page 5) and clicks on the icon next to Jones, they're taken to the form page (Page 6) editing the Jones record.  When the user deletes the row for Jones, I need them to return to the report page (page 6) and point to someplace near Jones.  Let's say the last name of King.  How would I accomplish this?  I'm guessing that when I go from the report to the form for the record Jones, I should somehow pass the value King.  Then if I delete, I'd pass back the value King.  However, I don't know how to get the value King from the report when the user presses the edit button for Jones.

                                  • 14. Re: How to I redirect to the row after a deleted row
                                    jacknomiz

                                    Hi PhilMan2.

                                    Maybe there is some programmatic way to refresh IR to a specific report page but I never had to do it.

                                    I figured that if I delete a record I can display IR with pagination reset back to page 1.

                                     

                                    What is your EMPNO? If it's just a next sequence number, you could make P5_EMPNO as P6_EMPNO - 1 when deleting record and returning back to P5 from P6.

                                    Or you could add a process in Page-Pre Rendering, to check if P5_EMPNO exists and put some logic in adjusting it.

                                     

                                    Thanks

                                    jack