Oracle APEX card templates and card regions already have quite a few options you can set via the APEX Builder.
In a card region, a card can have an action, but the options are limited to a link to another page or URL. What if you just want to click on a card and draw attention to the selected card and set some item value based on that selection? Something like this:
This approach needs some custom Dynamic Actions and CSS.
Create the card region
Let's start with the card region.
First upload some images as static application files (or any other location).
Next create a page with a card region. For this example, I simply used this query for the card region:
The cards only use the Media attributes:
Source: Image URL
URL: &IMAGE.
Next, you want to make the unselected cards a bit smaller, so a selected card can get the normal card size. For that, add this class to the card:
card-unselected
(the CSS will follow later).
Add an action to the cards:
Type: Full Card
Link: Redirect to URL
Target: #
Since we do not really want to go to some other page, we need to modify the behaviour of the link a bit. To do that, set this value in the Link Attributes:
data-action=select data-value=&COMBI.
Create a Dynamic Action
Now we can create a Click Dynamic Action.
Name: Get selected card
Selection Type: jQuery Selector
jQuery Selector: [data-action='select']
The first action is a Set Value to copy the card value to a page item.
Set Type: JavaScript Expression
JavaScript Expression: this.triggeringElement.dataset.value
The second action increases the size of the selected card to the normal size, and to make it bit more fancy, also sets a drop shadow. This action also has to reset the previously selected card to the smaller size.
Action:Execute JavaScript Code
Code:
$(".a-CardView").removeClass( "card-selected" );
$(".a-CardView").addClass( "card-unselected" );
this.triggeringElement.parentElement.classList.remove("card-unselected");
this.triggeringElement.parentElement.classList.add("card-selected");
hi, thanks to create this guide. i am trying to use Cards region for a page consists of Items and want user to click on a Card and there should be an action/da to store the selected card value in a Collection. i asked in Oracle Apex forum and a senior @InoL post this article link. i failed to set value in a page item, in this article there is no page item exists (or i misunderstood, which page item you are setting the value) where mentioned "The first action is a Set Value to copy the card value to a page item.", please help me to achieve what i want to do. regards
ReplyDeleteLook above the cards. There is an item with label "You selected option". That is the item for the Set Value.
ReplyDeleteI have tried this solution. It works nicely in apex version 21.1.0 but no longer in version 21.2.0.
ReplyDeleteHello. Great post.Howto get values as card_title?
ReplyDeleteRegards
If you need help on something else than the content this blog, you'd better ask this on an Oracle APEX forum.
DeleteI have tried the same but failed, Can i get the code?I tried but failed.
ReplyDeleteThere is no code involved. All steps are described here.
ReplyDeleteThere was a bug in APEX 21.2, so you need to install the latest APEX patch to get it to work in 21.2.
Hi Ino, thanks for your update. To download latest patch need CSI number. I just want to use it for learning purpose. From where I can download latest patch for 21.2 oracle apex version without CSI number. If you have any link please share or send an email on anil1063@gmail.com.
ReplyDeleteYou cannot download patches without a support contract. For learning purposes you can also use apex.oracle.com or register for the Always Free Autonomous Database.
ReplyDelete