Disable a Link in IR in Oracle Apex - oracle

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

Related

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.

Creating a Column Link in an Interactive Report -Oracle Apex

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.

How to know, in validation(PL/SQL), if a page item is updated? Similar to apex.item().isChanged in JS

In validation's PL/SQL,is there any way to get the status of a given page item to know if it is changed. Similar to the one in JS API, apex.item.isChanged()?
In the session information (accessed from the developer tools) we can see the status as "Updated" for page Items changed after rendering. How can we get that in the PLSQL in validations?
Any help would be appreciated.
Thanks
if it is a database item, could you select it from the db and compare it to the value on the page? something like :
declare
value varchar2(250);
begin
select your_column into value from your_table where id = :PAGE_ITEM_ID;
if value != :PAGE_ITEM_VALUE then
/*do _something_here*/
end if;
end;

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

Resources