问题
I have a checkbox item on my page (note: this is not inside a report) and I want to dynamically check the checkboxes when the page loads. I have a table which has all the checkbox types and a table which identifies which checkboxes that user has access to or in better terms should be checked.
My question is, within an Apex checkbox item how do you tell it to dynamically check a checkbox. I have it working in a report and my query looks like this:
SELECT at.name AS TITLE,
CASE
WHEN at.name IN (SELECT atp.name FROM preferences p) THEN apex_item.checkbox(1,at.value,'CHECKED')
ELSE apex_item.checkbox(1,at.value, 'UNCHECKED')
END AS CHECKBOX
FROM access_types at
Can I do something similar in an oracle apex checkbox item?
回答1:
Not sure it is exaclty what you want but if you simply need to initialize a checkbox item on page load, you can :
1 - Use the Source attribute of the checkbox item and set the following attributes :
- Source Used :
Always, replacing any existing value in session state
- Source Type :
SQL Query (return single value)
orSQL Query (return colon separated value)
depending if your checkbox item contains several checkboxes or not. - Source value or expression : your query that returns the right values.
2 - Use a Before header computation to compute your item :
- Compute Item : Your checkbox item
- Computation Point :
Before header
- Computation Type :
SQL Query (return single value)
orSQL Query (return colon separated value)
depending if your checkbox item contains several checkboxes or not. - Computation : your query that returns the right values.
Note: I use checkboxes in reports too, but I noticed that when you have a lot of rows, it is very slower than using simple HTML checkboxes, so if you think your report is slow, I suggest you to generate simple HTML checkboxes from your query :
SELECT
at.name AS TITLE,
CASE WHEN at.name IN (SELECT atp.name FROM preferences p) THEN
'<input type="checkbox" value="'||at.value||'" checked="checked" />'
ELSE
'<input type="checkbox" value="'||at.value||'" />'
END AS CHECKBOX
FROM
[...]
来源:https://stackoverflow.com/questions/12915748/oracle-apex-dynamically-check-checkbox-item-that-is-not-within-a-report