Oracle APEX Interactive Report 条件列链接显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28299582/
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 Interactive Report conditional column link display
提问by Uma Ilango
I have an interactive report displaying all the records from articles table. For a logged in author, I would like to display all the records, but the EDIT should be displayed only for those articles written by that author. In articles table, I have the column CREATED_BY
which has the author username.
我有一个交互式报告,显示文章表中的所有记录。对于已登录的作者,我想显示所有记录,但 EDIT 应仅显示该作者撰写的那些文章。在文章表中,我有一列CREATED_BY
有作者用户名。
I added a condition to Link Column as Value of Item / Column in Expression 1 = Expression 2 as Expression1=#CREATED_BY#
& Expression2= :APP_USER
我向链接列添加了一个条件作为表达式 1 = 表达式 2 中的项目/列的值作为 Expression1= #CREATED_BY#
& Expression2=:APP_USER
But this does not work. This is the first time I am taking this approach to display edit link based on a condition.
但这不起作用。这是我第一次采用这种方法根据条件显示编辑链接。
When I added the condition Value of Item / Column in Expression 1 is not null
and set Expression1 = #CREATED_BY#
, it was still not displaying edit link. So, I think that #CREATED_BY#
is returning null. But the record in table has a value & I also see it in report column.
当我添加条件Value of Item / Column in Expression 1 is not null
并设置 Expression1 = 时#CREATED_BY#
,它仍然没有显示编辑链接。所以,我认为这#CREATED_BY#
是返回空值。但是表中的记录有一个值,我也在报告列中看到它。
Can someone help? I don't know where I am going wrong.
有人可以帮忙吗?我不知道我哪里出错了。
回答by hmarques
The condition you use is for the column and not for each row so you will not be able to do it that way.
您使用的条件是针对列而不是针对每一行,因此您将无法这样做。
I think that the best way to achieve this is create a dummy column in your query that you will use as your edit link:
我认为实现这一目标的最佳方法是在您的查询中创建一个虚拟列,您将用作编辑链接:
SELECT
CASE
WHEN CREATED_BY = :APP_USER THEN
'<a href="' || APEX_UTIL.PREPARE_URL( p_url => 'f?p=' || &APP_ID. || ':<YOUR EDIT PAGE>:'||&SESSION.||'::NO::<PAGE ITEM>:'||COLUMN ID, p_checksum_type => 'SESSION') || '"><img src="/i/menu/pencil2_16x16.gif"></a>'
ELSE ''
END edit_link,
...THE REST OF YOUR QUERY...
You also have to change the display of the column under column definition to
您还必须将列定义下列的显示更改为
Standard Report Column
标准报告栏
and optionally you can remove the options under
并且您可以选择删除下的选项
Allow Users To: so the user couldn't hide/sort/... the column.
允许用户:因此用户无法隐藏/排序/...列。
Hope this can help you. Any doubt or further explanation just ask.
希望这可以帮到你。任何疑问或进一步的解释只是问。
回答by John Redmond
I was able to come up with the solution in APEX 5, but the same should apply to APEX 4.2. You can easily do this with the built-in APEX column linkand a case statementas hmarques was suggesting.
我能够在 APEX 5 中提出解决方案,但同样适用于 APEX 4.2。您可以使用内置的 APEX 列链接和hmarques 建议的case 语句轻松完成此操作。
Structure your query as follows:
构造您的查询如下:
SELECT CASE
WHEN CREATED_BY = :APP_USER THEN
'Edit'
ELSE
NULL
END EDIT,
...rest of query
Then, go to: Report Attributes> Your EditColumn > and scroll to the Column Linkportion of the page. Select the arrow next to the Link Texttext box, and select #EDIT#as the column link text.
然后,转到:报告属性> 您的编辑列 > 并滚动到页面的列链接部分。选择链接文本文本框旁边的箭头,然后选择#EDIT#作为列链接文本。
Also, set the Link Attributeswith this html code:
此外,使用此 html 代码设置链接属性:
class="t-Button t-Button--simple t-Button--hot t-Button--stretch"
This will make the column look like a button, and will not display the traditional pencil icon (which is the only drawback to this method).
这将使列看起来像一个按钮,并且不会显示传统的铅笔图标(这是此方法的唯一缺点)。
Don't forget to make the edit column a Standard Report Columnand good luck!
不要忘记将编辑栏设为标准报告栏,祝你好运!
John
约翰
回答by Bacs
This is a similar solution to hmarques, but it doesn't require building the whole link manually.
这是与 hmarques 类似的解决方案,但它不需要手动构建整个链接。
I would include a dummy column in the report query which contains either null, or if the current username matches CREATED_BY, a pointer to the "Edit" button image:
我会在报告查询中包含一个虚拟列,其中包含空值,或者如果当前用户名与 CREATED_BY 匹配,则是指向“编辑”按钮图像的指针:
select decode(CREATED_BY
,:APP_USER
,'<img src="#IMAGE_PREFIX#edit.gif" alt="">'
-- or your preferred image/hyperlink text
) EDITLINK
--, your columns
from ARTICLES
--etc
Use the standard column link functionality to pass parameters to your edit page, but use #EDITLINK#
as your column's Link Text. Don't forget to set the column's Display Type to "Standard Report Column". Personally I would also get rid of the column heading - it's a mandatory field, but you can set it to a single space.
使用标准列链接功能将参数传递到您的编辑页面,但#EDITLINK#
用作您的列的链接文本。不要忘记将列的显示类型设置为“标准报告列”。就我个人而言,我也会去掉列标题——它是一个必填字段,但您可以将其设置为一个空格。