Column as link in APEX 5 IR region - oracle-apex

I have APEX 5 app and want to create Interactive Report region with pl/sql source. What I want is to have some columns as link to another page. But, when I put in select, for example, select d_01, ..., '' || d_26 || '' d_26 I get column d_26 as text a href="f? ..., but not value as link.
What am I doing wrong?

You will have to unescape special characters of the column. Change Columns > Security > Escape special characters property of link column to No
Also, you can do this in a declarative way by changing Column Type from Plain Text to Link and then linking it to the desired page.

Related

Oracle Apex- Enter a value and convert it to a link

I have a Master Detial with 2 interactive grids.
I would like to be able to genrate a link based on user input....is that at all possible?
To give a simple example:
Lets say I have website like https://www.google.com/
I would like a user to enter anything...for example "Prague"
Once this is entered, I would like APEX to generate a URL from it to result in: https://www.google.com/Prague
Now I know that Google search does not work like that, but I need that sort of mechanism for our internal company app. Is this possible?
Ideally , once the grid is saved the link in the Interactive grid only said "Prague" but if I click it, it would direct me to https://www.google.com/Prague
This can be achieved using the "JavaScript Initialization Code" attribute of the column.
Example on the EMP sample table (*). Functionality is that when a user enters a value in the ENAME column, it is converted to a google search url.
Create an editable IG on table EMP
Set the type of column ENAME to "Text Field"
Set "Javascript Initialization Code" for column "ENAME" to
function(config) {
config.defaultGridColumnOptions = {
cellTemplate: '&ENAME.'
};
return config;
}
Notice that the column now is a link. A user will have to open in new window to get the actual link value, since clicking the column will active the edit mode.
(*) Sample dataset can be installed using SQL Workshop > UTILITIES > Sample Data Sets > EMP/DEPT
yes, you can let user enter the value and by creating a dynamic action(choose the when attribute as whatever suits you) you can take that value and on another column, use that column as &Columnvalue. for example and concatanate it by using to base url using ||

Conditionally display a link within an interactive data grid in Oracle APEX

I want to display a link in a data grid, only when a certain condition is met for that record. I also want that link to be dynamic, based on the data in the data grid. Lastly, the data grid is linked to a header record displayed above the data grid region.
Create a hidden field that will be used for the Link Text. Column Name = HIDDEN_LINK_TEXT. Type = Hidden. This field will have a source type of SQL Expression. Q in this example query represents the data grid's source select statement. Parenthesis are required in the SQL Expression text box for the hidden field.
(SELECT '[Static link text]' FROM TABLE B WHERE B.RECORD_ID =
Q.RECORD_ID AND B.FIELD_1 = Q.FIELD_1 AND B.FIELD_2 = Q.FIELD_2)
Create a displayed field for the link. Column Name = DISPLAYED_LINK Type = Link.
Link Text should reference the hidden field we created in step 1. Link Text = &"HIDDEN_LINK_TEXT". Include the ampersand and double quotes.
Set the link target to what your target page. Include any variables or "Set Items" which you want to set when linking to the page.

How to only display 'Edit' link on certain rows on apex interactive grid?

I have an interactive report apex5.0 which contains several fields.
Would like to disable 'edit' pencil option link where payment_date & code is populated.
Link is to be enabled only where payment_date & code is null.
Disable the edit button for a particular row, based on a specific value in its column.
For ex. If a grid has 3 columns A,B,C and if B contains "Apple", and '01-jan-17', the edit button for that row must be disabled.
What are the different options to do this kind of functionality in apex5.0, enable & disable "EDIT" based on certain criteria?
You could also add a case statement to your report's query.
E.g.
(Case when [some logic] then
--display link
'<img src="#IMAGE_PREFIX#menu/pencil16x16.gif" alt="" />'
End) as col_link
The above example will only display a link if the case statement is met. The link will point to page 47 and we will pass the query's Id column to page 47's item P47_ID
In order to treat this new column as a link you must change the "display as text" property to "standard report column"; you can achieve this when editing the report attributes.
One way is to use JavaScript on page load:
Let's asume that first column is with ID and used to show edit link. Second column is your product name like Apple. Just disable click on this element(cell with ID) or change link, img etc.
var table = $(".a-IRR-table tbody");
table.find('tr').each(function (i, el) {
var $tds = $(this).find('td'),
productId = $tds.eq(0).text(), //first column with ID and edit link
product = $tds.eq(1).text(), //second column
Quantity = $tds.eq(2).text(); //third column
if (product == 'Apple'){
$tds.eq(0).click(false);
$tds.eq(0).replaceWith('');
}
});
Thanks to this answer for JavaScript: Loop Through Each HTML Table Column and Get the Data using jQuery
EDIT:
To hide value based on your Query use CASE. For example:
SELECT
CASE
WHEN B = 'Apple' THEN
'<img src="#IMAGE_PREFIX#edit.gif" alt="">'
ELSE ''
END edit_link,
A,B,C
FROM TABLE_NAME
Click on column edit_link and make it of type Link
Choose your target to edit page
For link text select #EDIT_LINK#
Escape special characters must be set to NO
On Report Atributes set **Link Column** to **Exclude Link Column** (you have custom link column so don't display original link)
*Check your online workspace, page 3*

How do I display a new line within column data in an Apex Interactive Report

I'm using Apex 4.2 and Oracle 11.g
I have a column called "Transaction Detail" that I display in an interactive report. The report column's Display Text As selection is set to "Standard Report Column".
The report column is selected from a varchar2 table column called transaction_detail. I'm just building the table as well. The transaction_detail table column is populated from a Procedure with the following code:
Insert into mail_log (transaction_type, transaction_detail)
Values ('FTP Transaction',
'Filename=' || p_image_filename ||
'<br/>' || 'Event Description=' || l_event_description);
The procedure code can be easily changed.
The report just displays:
Filename=myfile.jpg<br/>Event Description=my description
I've tried using CHR(13) in the procedure instead of the html characters and then tried to replace the CHR(13) in apex with html characters. Instead of simply selecting the column:
, transaction_detail
I tried:
, REPLACE(transaction_detail, CHR(13), '<br/>')
but I couldn't get past an Apex error: ORA-12899: value too large for column "APEX_040200"."WWV_FLOW_WORKSHEET_COLUMNS"."DB_COLUMN_NAME" (actual: 49, maximum: 30)
Shouldn't Apex be able to interpret the as a new line if the column is a Standard Report Column?
Thanks for looking at this.
This was answered on the OTN forum by Jorge (jrimblas) and others. The link to that discussion is above. Short summary, In the stored procedure I got rid of the '<br/>' and replaced it with CHR(13). Then, in the Apex interactive report, I did NOT need to change the column to "Standard Report Column". I placed the following in the "HTML expression" for the column.
<div style="width:240px">
<pre style="font-family:Arial; font-size:12px; white-space:pre-wrap">#TRANSACTION_DETAIL#</pre>
</div>

Capture values of a shuttle list

I am using APex 4.2
I have a page (page 31) with a shuttle list. The list contains several job categories (a, e, x, c, etc). I have a button on that page that generates a report based on the selected job category. I click my button, a query runs, and it takes me to a report page (page 27). The query is along these lines
select * from 'table'
where (instr(':'||:P31_JOB_CATEGORY||':',':'||JOB_CATEGORY||':') > 0)
where P31_JOB_CATEGORY is represented by a shuttle list. This gives me the desired results on page 27, however, is there a way to capture each selected job category that was selected in the shuttle list on page 31 and pass it to page 27 to be displayed? It would be nice to have it stored in a concatenated string of some sort for easy handling, i.e. A, E, C, X.
Any help would be greatly appreciated. Thanks in advance.
The reason is in how shuttle values are saved to session state and how the apex URL is constructed.
Shuttle values are constructed, as you have seen, by concatenating the selected values with a colon. So for example, I have a shuttle on ENAME from EMP, select 3 values and submit the page. Session state for the shuttle is: URUGUAY:HOWARD:M BENZ.
Now say that you redirect to another page, setting an item with the value of this shuttle item. The URL will look like this: f?p=54687:6:100741653098795::NO::P6_TEXT:URUGUAY:HOWARD:M BENZ
The apex URL is constructed by using colons. You putting values in there which has colons simply doesn't work for apex.
Solution? You could submit the page and use a computation to replace the colons, and then branch away to the destination page.
For example, with my enames I'm replacing the colon with a ~: URUGUAY~HOWARD~M BENZ. On your destination page you can then use this value and adapt your sql or use a computation in before/after header to replace the seperator again.