Oracle Apex - 动态勾选不在报告中的复选框项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12915748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle Apex - Dynamically check checkbox item that is not within a report
提问by medium
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:
我的问题是,在 Apex 复选框项目中,您如何告诉它动态检查复选框。我让它在一份报告中工作,我的查询如下所示:
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?
我可以在 oracle apex 复选框项目中做类似的事情吗?
回答by Yann39
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 Sourceattribute of the checkbox item and set the following attributes :
1 - 使用复选框项的Source属性并设置以下属性:
- 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.
- 使用的来源:
Always, replacing any existing value in session state
- 源类型:
SQL Query (return single value)
或SQL Query (return colon separated value)
取决于您的复选框项目是否包含多个复选框。 - 源值或表达式:返回正确值的查询。
2 - Use a Before header computationto compute your item :
2 - 使用Before 标头计算来计算您的项目:
- 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.
- 计算项目:您的复选框项目
- 计算点:
Before header
- 计算类型:
SQL Query (return single value)
或SQL Query (return colon separated value)
取决于您的复选框项目是否包含多个复选框。 - 计算:您的查询返回正确的值。
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 :
注意:我也在报告中使用复选框,但我注意到当你有很多行时,它比使用简单的 HTML 复选框要慢得多,所以如果你认为你的报告很慢,我建议你从你的询问 :
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
[...]