本文介绍了Oracle Apex-动态选中不在报表中的复选框项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面上有一个复选框项(注意:这不在报表内),并且我想在页面加载时动态地选中该复选框.我有一个包含所有复选框类型的表和一个表,该表标识应检查用户有权访问或更合适的复选框.

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.

我的问题是,在Apex复选框项目中,如何告诉它动态检查复选框.我在报告中使用它,查询如下:

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

我可以在oracle apex复选框项目中做类似的事情吗?

Can I do something similar in an oracle apex checkbox item?

推荐答案

不确定所要的是什么,但是如果您只需要在页面加载时初始化复选框,则可以:

Not sure it is exaclty what you want but if you simply need to initialize a checkbox item on page load, you can :

1-使用复选框项的 Source 属性并设置以下属性:

1 - Use the Source attribute of the checkbox item and set the following attributes :

  • 使用的来源:Always, replacing any existing value in session state
  • 源类型:SQL Query (return single value)SQL Query (return colon separated value),具体取决于您的复选框项目是否包含多个复选框.
  • 源值或表达式:返回正确值的查询.
  • 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-使用在标头计算之前来计算您的项目:

2 - Use a Before header computation to compute your item :

  • 计算项:您的复选框项
  • 计算点:Before header
  • 计算类型:SQL Query (return single value)SQL Query (return colon separated value)取决于您的复选框项目是否包含多个复选框.
  • 计算:您的查询返回正确的值.
  • 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.

注意 :我也在报表中使用复选框,但是我注意到,当您有很多行时,它比使用简单的HTML复选框要慢得多,因此如果您认为您的报告很慢,建议您从查询中生成简单的HTML复选框:

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
  [...]

这篇关于Oracle Apex-动态选中不在报表中的复选框项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 03:43