1

I have a cards region on page 1 in my application which is paged and is set to show 32 cards on a page. When the user clicks a card, it takes the user to a different page which is page 11. There is a button on page 11 that brings the user back to page 1.

When the user comes back to page 1, I am taking him to the exact position where he was before going to page 11. For example, if he clicked card # 38 to go to page 11, when he comes back to page 1, I am taking him to card # 38.

I am doing it using the following JS API

apex.region("prods").call('gotoPage', $v("P1_CARDS_PAGE"));
$(window).scrollTop(apex.item("P1_SCROLL_POS").getValue());

Where P1_CARDS_PAGE is the number of page of paged cards region. Which will be page 2 in the above example. And P1_SCROLL_POS is the position of the card on that page where the user clicked.

Problem The problem I am having is that my JS code fires before the cards region is fully rendered when the user lands on page 1 where cards are displayed. It sends the user to the relevant page number in the cards region, but does not maintain the card position.

Is there any way of knowing when an Oracle Apex cards region is rendered completely? I want to check that when the oracle apex cards region is rendered completely and then want to fire that javascript code after that.

I have tried to use #TIMING# substitution string but I can only use that to just display how much time the region has taken to complete and can't use that to fetch the value in a page item

Thanks

Ahsan Anwar
  • 39
  • 1
  • 1
  • 9
  • Pls tag correctly: don't tag "oracle11g" unless you are using 11g (which is an old an unsopported db version). Also don't tag "oracleapplications" since that that refers to Oracle's ERP applications and not the Oracle APEX low code platform. The tag "apex" refers to the Salesforce product (not related to Oracle APEX). – Koen Lostrie Dec 28 '22 at 18:18
  • Hi Koen, Thanks for letting me know. I am using Oracle 11g DB. For the rest, I'll use tags correctly. – Ahsan Anwar Dec 29 '22 at 06:59
  • Have a look at [this](https://community.oracle.com/tech/developers/discussion/4286750/resetting-the-pagination-of-ig) discussion. It refers to an example in the interactive grid cookbook using session storage – Koen Lostrie Dec 30 '22 at 13:55

2 Answers2

0

Create a Dynamic Action that executes 'After Refresh' of the region.

This will execute at a time appropriate for JavaScript to execute after rendering.

Don't forget to check 'Fire on initialisation' if you want it to also execute on page render, not just after manual refresh or a pagination event.

I use it for such things as hiding a region if no data is found.

Scott
  • 4,857
  • 3
  • 22
  • 33
  • Hi Scott, I am not doing a manual region refresh. I want to fire that code when user lands on that page where I have the cards region. – Ahsan Anwar Dec 29 '22 at 07:29
  • @AhsanAnwar did you read the full answer ? The 3rd paragraph exactly explains what to do when you're not doing a manual refresh. – Koen Lostrie Dec 29 '22 at 10:18
  • @Koen I read that. But that will still not work if I want to move onto the next level in a paged card region e.g. on page 2 or 3. It works fine if I am on the first page of the region. – Ahsan Anwar Dec 29 '22 at 11:29
  • I used this action all the time to execute code as the user paginates through a set of records. – Scott Dec 30 '22 at 06:02
0

The best bet would be to use the Universal Theme API if you are using it. Put the following code block to page level attribute Execute when Page Loads.

$(window).on('theme42ready', function() {
    setTimeout(function() {
        apex.region("prods").call('gotoPage', $v("P1_CARDS_PAGE"));
        $(window).scrollTop(apex.item("P1_SCROLL_POS").getValue());
    }, 200);
});

Check the docs.

davidm
  • 1,570
  • 11
  • 24
  • Thanks David. I have tried this. I guess this will work if I am browsing cards from the first page of the paged cards region? As I have mentioned that I have paged the card region, so if I am on a card say 72, then this code will not work as the theme initialization event will occur but page 3 of the card region will load after that. – Ahsan Anwar Dec 29 '22 at 10:12