Oracle Apex - Dynamically check checkbox item that is not within a report

时光总嘲笑我的痴心妄想 提交于 2019-12-23 02:39:51

问题


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) or SQL 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) or SQL 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!