Oracle Apex - How Show Image in a Dynamic List - oracle-apex

I have created dynamic list for sub-menu page,now i want to show image for each list entry

A nice feature is to use Apex Font Awesome icons.
Here's an example of a dynamic list query, based on Scott's DEPT table:
select
null lvl,
dname,
'#' target,
null is_current,
case when deptno = 10 then 'fa-thumbs-o-up'
when deptno = 20 then 'fa-thumbs-o-down'
end icon
from dept
order by deptno
When you add the list to the page (as a region), navigate to its "Attributes" and modify template options by setting the "Display icons" property to "For all items".
Once you run the page, you'll see a thumb up icon by department 10 and thumb down for department 20.
List of all available icons is here.

The answer is in Example 1 in the SQL page of the Create List wizard:
Example 1:
SELECT null,
ENAME label,
null target,
'YES' is_current,
'#APP_IMAGES#del.gif' image, -- <-- HERE
'width="20" height="20"' image_attrib,
ENAME image_alt
FROM emp
ORDER BY ename

first use query like below:
select
1 level,
dname label,
'#' target,
null is_current,
'IMAGE'||img_name image
from dept
order by deptno
with this query img_name set as class for each card. after that use this javascript code on page load:
var spns = document.getElementsByTagName("span");
for (var i = 0; i < spns.length; i++) {
if (spns[i].className.includes('-IMAGE')) {
spns[i].style.backgroundImage = "url(#IMAGE_PREFIX#"+spns[i].className.substring(5)+")";
$('.'+spns[i].className.substring(5)).css("background-size", "cover");
}
}
for this background image url should exist images on ords server.
good luck

Related

How to display and update the records I have added/insert in the Apex interactive report

I've created an interactive report to add/update/delete employee info records in custom db table.
My end user requirement is upon entering the employee number in the EMPNO field, all the details from the oracle standard table such as employee name, marital status, gender, bday must be auto generated in the form and they will only manually input the location name and mode of exit.
Now I created 3 pages: 1.home page, 2.add page, 3.update page
On page 1 (home page)
I have here the select SQL
with checkbox
On page 2 (add page),
In the page processing portion
I have
EventAddRecord
Source: db , plsql code
Here's my sample code:
BEGIN
INSERT INTO EMPINFOTBL
(PERSON_ID,
EMPLOYEE_NUM,
EMPLOYEE_NAME,
MARITAL_STATUS,
BDATE,
GENDER,
LOCATION_NAME,
MODE_OF_EXIT
)
VALUES
(SELECT PERSON_ID FROM
PER_PEOPLE_X WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT EMPLOYEE_NUMBER ID FROM
PER_PEOPLE_X WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT FULL_NAME FROM
PER_PEOPLE WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT MARITAL_STATUS FROM
PER_PEOPLE WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT DATE_OF_BIRTH FROM
PER_PEOPLE WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT GENDER FROM
PER_PEOPLE WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
:P2_LOCATION_NAME,
:P2_MODE_OF_EXIT
);
END;
Buttons
SAVE with dynamic action
When click add button if True submit page
Now my problem is how to do the update when I click the check box,
I want my record to be displayed in the form because currently when I click the check box the form is null
To create a new record (using Page 2), you'd create a select list item which is based on per_people table; you'd display any information you want, but you'd return employee ID:
select full_name as display_value,
employee_num as return value
from per_people
order by full_name;
After selecting desired person, enter values into P2_LOCATION_NAME and P2_MODE_OF_EXIT items. When you hit the "Save" button (which submits the page), run the process (I modified what you wrote; should be way simpler):
INSERT INTO empinfotbl (person_id,
employee_num,
employee_name,
marital_status,
bdate,
gender,
location_name,
mode_of_exit)
SELECT person_id,
employee_number,
full_name,
marital_status,
date_of_birth,
gender,
:P2_LOCATION_NAME,
:P2_MODE_OF_EXIT
FROM per_people
WHERE employee_num = :P2_EMPLOYEE_NUM;
As of updating existing values: I'd again suggest you to use the Wizard as it creates everything you need - form page is based on empinfotbl table, while "Edit" button in Interactive report sends the ID value to form page whose pre-rendering process fetches data related to employee identified by passed ID.
If you created your own page, you'll have to do it all yourself.
You said:
I want my record to be displayed in the form because currently when I click the check box the form is null
Form items are empty because Apex didn't know what to fetch. As I said: pass ID value, create pre-rendering process. Or start over with the Wizard (I prefer that option).
#Littlefoot has given a perfect answer already, here are just some extra steps that might guide you to a solution (it's the "or start over with the wizzard" piece from Littlefoot's answer). I'd suggest looking how apex generates its pages when you do it out of the box. Just for testing, follow these steps
Create a new page of type "Interactive Report" and make sure to check the "Include Form Page" attribute
Give the form page a name and select "PER_PEOPLE" as table/view name
In the 2nd page of the dialog, select the primary key column of PER_PEOPLE: person_id
Click "Create Page"
You now have a working form and report that you can further customize to your specific requirements. It should give you a good idea of how a form and a report is generally configured in APEX and it saves you a ton of time
Notices how in the report page:
The edit link has the form page as target and passes the id
The CREATE button has the form page as target without the id
In the form page
No custom code is needed to initialize the form data for the current record. Instead the native process of type "Form - Initialization" is used.
No dynamic actions are used to perform the inserts - for a form that is a bad practice. Avoid it.
No custom code is needed to perform the inserts or update. Instead the native process of type "Form - Automatic Row Processing" is used.
Study these pages and apply similar logic to your own pages. It'll be a better app.

Get Select list Item value in IG report column for DML operation

I have a Select list filter on the top of the page. I want its return value to get into any column which I create in IG report automatic DML process.
Suppose, Select list has a value "Step", when I add a row in IG report, that value should be saved into DB for one column which is hidden on UI.
I tried but sometimes it stores the value which I selected in Select list item as my last selection not the current one. Do I need to create Application item for this? Please help. TIA
In this case there is a table ig_tickes with a status column. On the page there is a page item P131_STATUS (select list) with values "OPEN" and "CLOSED". There is an interactive grid on table ig_tickets with column STATUS hidden. Functionality is that user selects a value from the select list and then clicks "Add Row".
Give the interactive grid a static id of "tickets"
Create a dynamic action on change of P131_STATUS with a true action of type "execute javascript code" and code:
var model = apex.region("tickets").call("getViews").grid.model;
model.getOption("fields").STATUS.defaultValue = apex.item( "P131_STATUS" ).getValue();
That's all there is to it.

Creating Dynamic LOVs

I have a form in oracle apex with more than seven items on it. they are
SUBJECT_ID,GRADE_ID,DOMAIN_ID, CATEGORY_ID, STANDARD_CODE, STANADARD_STATEMENT, LEARNING_TARGETS.
I want these items SUBJECT_ID,GRADE_ID,DOMAIN_ID, CATEGORY_ID, STANDARD_CODE type to be select list. additionally, I want to make LOVs for each of these items.
LOV for SUBJECT_ID: I am making this LOV using a table SUBJECTS having TWO columns. MY query is SELECT SUBJECT_ID, SUBJECT_NAME FROM SUBJECTS It's working fine.
LOV for GRADE_ID: I am making this LOV using a table GRADES having TWO columns. MY query is SELECT GRADE_ID, GRADE_NAME FROM GRADES It's working fine.
LOV for DOMAIN_ID: I am making this LOV using a table DOMAIN having TRHEE columns. MY query is SELECT DOMAIN_ID, DOMAIN_NAME FROM DOMAIN WHERE SUBJECT=:P48_SUBJECT_ID. It's working fine.
LOV for CATEGORY_ID: I am making this LOV using a table CATEGORIES having FOUR columns. MY query is SELECT CATEGORY_ID, CATEGORY_NAME FROM CATEGORIES WHERE DOMAIN=:P4.8_DOMAIN_ID It's working fine.
LOV for STANDARD_CODE: I am making this LOV using a table CURRICULUM having MORE THAN EIGHT columns. MY query is SELECT CURRICULUM_ID CI, STANDARD_CODE SC FROM CURRICULUM WHERE SUBJECT=:P48_SUBJECT_ID AND GRADE_ID=:P48_GRADE_ID AND DOMAIN_ID=:P48_DOMAIN_ID AND CATEGORY_ID=:P48_CATEGORY_ID. It's not working for me.
Kindly tell me how I can correct the 5th LOV. Thanks
I wouldn't say that any of LoV queries you posted return desired result and "work fine". Their format should be:
select display_value, --> you see it on the screen
return_value --> you don't see it; it is stored into the table
from ...
Code you posted suggest just the opposite, e.g.
SELECT SUBJECT_ID, --> are you REALLY displaying ID to users and
SUBJECT_NAME --> storing NAME into the table?
FROM SUBJECTS
As of your final LoV: just as MT0 commented, we have no idea what "not working" means. You posted a whole lot of more or less useless information (queries that "work"; what should we do with them?), but said nothing about problem you have.
Therefore, I'll guess: you forgot to include
P48_SUBJECT_ID, P48_GRADE_ID, P48_DOMAIN_ID, P48_CATEGORY_ID
into the Parent Item(s) property within the "Cascading List of Values" section, e.g.
Note that query you posted presumes that all page items have a value; if any of these is NULL, query won't return anything so that would be my second guess:
SELECT curriculum_id ci, standard_code sc
FROM curriculum
WHERE ( subject = :P48_SUBJECT_ID
OR :P48_SUBJECT_ID IS NULL)
AND ( grade_id = :P48_GRADE_ID
OR :P48_GRADE_ID IS NULL)
AND ( domain_id = :P48_DOMAIN_ID
OR :P48_DOMAIN_ID IS NULL)
AND ( category_id = :P48_CATEGORY_ID
OR :P48_CATEGORY_ID IS NULL)
In that case, switch the "Parent required" property OFF.

How to include Tree and Master Detail in same page

I am new to Oracle Apex. I am trying to create a 3 column page with 3 regions for tree structure, master detail screen and customized buttons respectively. I was able to create Tree in one page and Master-Detail in different page. When I bring them into one page, tree is not displayed.
When I click on any node of tree I am redirected to master-detail page and data is shown. But I need to display Master-Detail in same page where my tree is present but in a new region instead of redirecting to new page.
SQL Query of tree:
select case
when connect_by_isleaf = 1 then
0
when level = 1 then
1
else
-1
end as status
,level
,name as title
,null as icon
,id as value
,null as tooltip
,'f?p='||:APP_ID||':'||4||':'||:APP_SESSION as link
from (
select to_char(d.DEPARTMENT_ID) id
,to_char(null) parent_id
,d.DEPARTMENT_NAME name
from DEPARTMENTS d
union all
select t.DEPARTMENT_ID || '_' || task_configuration_id
,to_char(t.DEPARTMENT_ID)
,t.TASK_NAME
from TASK_CONFIGURATION t
)
start with parent_id is null
connect by parent_id = prior id
The same query works when creating a tree as new page, but doesn't work when included in Master-Detail page(made 'NULL' as Link in select list). Am I missing any configuration! please help..
Also, any help on creating the 3rd column for including custom buttons region will be a great help.
the problem might be the branch or leave
the answer = is leaf 5 or more
= is branch 5 or more
this the answer might be
when connect_by_isleaf = 5 then
when connect_by_isbranch = 5 then
that might conclude my opininion or suggestion

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*