Creating a Column Link in an Interactive Report -Oracle Apex - oracle

I am using Apex 20.1.0.00.13, trying to create link on a column of a Classic Report.
I have followed the step to create the link for a column and redirect it to a page in the same application as the steps below :
To create a link to another page, in the Link Builder - Target dialog:
Type - Select Page in this Application.
Page - Specify the target page number.
Set Items - Select a Name and Value to specify session state for an item.
Clear Session State, Clear Cache - Specify the page numbers on which to clear cache. To specify multiple page, enter a comma-delimited list of page numbers.
Rest Pagination - Select Yes to reset pagination for this page.v
Advanced, Request - Specify the request to be used.
Click OK.
But when I am setting the item and values to specify session state for an item, the Set Items : Name doesn't populate the columns, it appears blank, Could someone let me know where I am going wrong.
I am trying to achieve a link from page 1 say a row with dept no - 2, to be directed to page 2 with details of dept 2 . Is there any other way to do it. Since its a column and not an item I am unable to pass it as a parameter to the next page.
Thanks in advance !

Right; there are no "items" here, you have to create hyperlinks within the report.
Suppose that this is classic report's query:
with test (id, name) as
(select 1, 'Google' from dual union all
select 2, 'Yahoo' from dual union all
select 3, 'Bing' from dual
)
select
id,
'<a href="' || case
when name = 'Google' then 'https://www.google.com'
when name = 'Yahoo' then 'https://www.yahoo.com'
when name = 'Bing' then 'https://www.bing.com'
end
|| '" target="_blank">' || name || '</a>' as link
from test
order by name;
Go to LINK column's properties and set "Escape special characters" to "No". Run the report; everything should work OK.
If - as you say - use it to navigate to another page in your application and set some items to some values (from the IR), then you'd do something like this:
SELECT
'f?p=&APP_ID.:217' ||
':&APP_SESSION.::NO::P217_ID' ||
':' || r.id
as link, ...
FROM my_table r ...
In other words: it navigates to page 217 and passes r.id column value into P217_ID item which is located on page 217.
link column from such a query can be referenced when creating a link column. It would be a
link to custom target
target type = URL
URL = #link# (literally, type #link#)

Probably you could change and merge these two pages into one Master-Detail page. This way you could use the built in lookup function.

Related

Disable a Link in IR in Oracle Apex

I have an Issue. I have three columns in my Interactive Report Table. First column is MID, its is hidden. The other columns are MNAME and Revenue. MID is the ID of MNAME. When ID is not null, certainly I am filling its MNAME. When ID is null then it is named in my query as 'Others'.
I have created a link for MNAME to other page in the Application. I would like to disable the link, when MID is null. Or in other Words, when MNAME is 'Others' then must be the Link disabled. How can I do this ?
Thank you so much in Advance for your Help and Comments.
In Apex itself, you can't as there's no "condition" for the "Link" property. Therefore, create a link yourself, within the Interactive Report's query.
For example:
select mid,
mname,
revenue,
--
case when mid is null then null
else 'Click here'
end as link
from your_table
In link column's property palette, set Escape special characters to "No". Run the page; link should be visible only for rows where MID column's value isn't NULL.
If you're navigating to another page in your application,
then 'Click here'
If you want to pass values to another page:
then 'Click here'
--------- ------- ======== ======
to P14 page pass items from P1 page

In Oracle apex 20.2, What is the javascript to get the selected tree node id

Good day,
I am running orcl apex 20.2. I have a tree region with a simple table: id, title, parent_id.
I am struggling with the JS to get the selected node id, and store it in a page item. My JS skills are very week. I have been trying to use a dynamic Action to execute JS and use a treeNodeAdapter, but the object returned is a jQuery object. I have no idea what to do at that point.
Given the table above, can someone please write back the exact JS I would need in the DA to capture the selected id and save it to the page item...
Pls & thnx
Nikita
Here's how (based on Scott's EMP table).
Suppose it is page 70 which contains the tree region. Create a page item on it (for example, P70_EMPNO).
The tree query looks like this (pay attention to the link column; once clicked, it stores the selected node value into the P70_EMPNO page item):
select
case when connect_by_isleaf = 1 then 0 when level = 1 then 1 else -1 end as status,
level,
ename || ' (' || empno ||')' as title,
'icon-tree-folder' as icon,
empno as value,
ename as tooltip,
--
'javascript:$s(''P70_EMPNO'', '''||EMPNO||''')' as link --> this
from emp
start with mgr is null
connect by prior empno = mgr
order siblings by ename;
The result (when you click on the JAMES node):
P.S. It looks that your keyboard is broken; quite a few letters are missing.

Oracle APEX - how to mark a classic report row as selected

I have a classic report where the rows are displayed in form of cards. I need to mark one card as selected whenever the report is loaded, perhaps by changing background color of that card.
The report is based on one SQL query and selected card should be based on querying another table. If a different card is selected I want the database to be updated to that selection.
How can this be done? I'd appreciate any pointers in the right direction.
I gave the region a static id but do not see how I can access individual rows - cards in this case
Presumably you are using the Universal Theme's "Cards" report template. That can handle highlighting via icons or colors. I have set up an example based on the EMP table here on apex.oracle.com (login as demo/demo).
My query:
select
ename card_title,
ename card_subtitle,
job card_text,
hiredate card_subtext,
'' card_modifiers,
apex_page.get_url(p_items=>'P6_EMPNO',p_values=>empno) card_link,
case when empno = :P6_EMPNO then 'u-color-39' else 'u-color-29' end card_color,
case when empno = :P6_EMPNO then 'fa-check' end card_icon,
'' card_initials
from emp
I have a hidden page item called P6_EMPNO, and when the user clicks on one of the cards that gets set by this link:
apex_page.get_url(p_items=>'P6_EMPNO',p_values=>empno) card_link,
Then that is used to specify an icon and different color for the card via these:
case when empno = :P6_EMPNO then 'u-color-39' else 'u-color-29' end card_color,
case when empno = :P6_EMPNO then 'fa-check' end card_icon,
You can find out all about Universal Theme cards, colors etc. at https://apex.oracle.com/ut/

APEX Select List based on query

APEX 4.2. I have Select List on form, based on query:
SELECT empno || ' ' || ename AS d, empno AS r
FROM emp
When select list expanded there two concatenated fields displayed.
But when some value selected and list collapsed I need only Ename displayed on form. So I need only JONES on pic 2 without number. Of course, return value must be empno anyway.
[EDIT] I mean I need both Empno and Ename displayed when Select List opened, only Ename displayed when it collapsed and always Empno returned.
Try adding another textfield to catch the name and place it over the select list.so every time you select an item, the value displayed is controlled in a separate container. You can try it by doing this:
Aside from the SELECT LIST ITEM you have created. Add another TEXTFIELD.
Then on the Main Page under Javascript > Execute when Page Loads
Paste this code:
$('#P5_SELECT_CONTAINER div:nth-child(2)' ).append($('#P5_TEXT'));
var s_width = Number($('#P5_SELECT').css("width").replace("px",""));
$('#P5_TEXT').css({"width":(s_width-22)+"px","position":"relative","right":s_width+"px","pointer-events":"none"});
But first youll be needing the name/id of your select list and the textfield you created. For this code,
select list id = P5_SELECT
textfield id = P5_TEXT
Just replace them(selectlist and textfield id) with what you already have.
Then create a dynamic action
EVENT = Change
SELECTION TYPE = ITEM
ITEM = P5_SELECT (or in your case Name of your SELECT LIST)
ACTION = EXECUTE JAVASCRIPT
then paste this code
var sel = $('#P5_SELECT option:selected').text();
var substr_sel = sel.substr(sel.indexOf('-')+1).trim();
$s('P5_TEXT', substr_sel);
console.log($v('P5_TEXT')); -- just to check if return is correct.
NOTE:just play with the width so that only the up/down arrow of the select list is displayed.
Hope this Helps

How can I create a select list without specifying its List of Values?

I have a form which has two select lists. The first one is prepopulated with an SQL query and has a dynamic action to set the value of the second list based on what is selected in the first.
I tested this out with a select list-textbox combination and it works just fine. However when I try to change the textbox into a select list then I am forced to also provide a "list of values" which overwrites my dynamic action.
How can I create a select list without specifying its List of Values?
Some clarification about my situation.
I have 2 tables: Wines and Winegroups.
+---------+------------+
| Wines | Winegroups |
+---------+------------+
| WineID | GroupID |
| Name | Name |
| GroupID | |
+---------+------------+
In APEX I have a form like this:
When the page is loaded, the first select list will get filled with values using this query:
select distinct Name, GroupID from Winegroups
Furthermore there is a dynamic action defined like this which fires whenever a group is selected. This is supposed to change the values inside the 'Wines' select list.
Event: Change
Selection type: Items on P5_GROUPID
Action: Set value
Page items to submit: P5_GROUPID
Affected elements: Items on P5_NAME
select distinct Wines.Name, Wines.WineID id
from Wines
left join Winegroups
on Wines.GroupID = Winegroups.GroupID
where Winegroups.Name = :P5_GROUPID
order by 1
The second select list uses the same query. When I execute my program the first select list is filled with groups nicely but the second one never gets any values.
Starting in apex 4.1, it is no longer necessary to use a dynamic action to get one select list to populate based on the value selected in a prior one. To get the functionality you want, you should be able to just do:
Disable or remove the current dynamic action.
Go into the Wines select list page item (P5_NAME).
In the List of Values section, for the Cascading LOV Parent Items field, select the winegroup select list item (P5_GROUPID).
The Page Items to Submit field will appear in that same section. Select the P5_GROUPID there as well.
In the list of values definition, put your query just as you wrote it above:
select distinct Wines.Name, Wines.WineID id
from Wines
left join Winegroups
on Wines.GroupID = Winegroups.GroupID
where Winegroups.Name = :P5_GROUPID
order by 1;
Edit to answer to question in comments:
When you do:
select distinct Name, GroupID
from Winegroups;
for a select list it displays name to the user, but stores the groupid. If you wanted to use name, you could do:
select name d, name r
from winegroups;
as your winegoup select list query. Then the value in P5_GROUPID would actually be the name and you could join it to winegroups.name in the wines select list query. Of course you should also rename P5_GROUPID if you were going to do this.
But I would probably just leave it the way it is. This way you actually don't need the join in your second query. You could just make it:
select wines.name, wines.wineid
from wines where groupid = :P5_GROUP_ID.
This would be the cleanest implementation.

Resources