简体   繁体   English

根据 oracle 顶点中的条件更改梭的文本颜色

[英]Change the text color of a shuttle based on a condition in oracle apex

I have two different tables in oracle apex, the first one is the documentation table which contains KPI's, the second one is the results table which contains all the KPI's results.我在 oracle 顶点中有两个不同的表,第一个是包含 KPI 的文档表,第二个是包含所有 KPI 结果的结果表。

I have created a shuttle in a page to choose KPI's from documentation table then, insert the results into the result table.我在页面中创建了一个穿梭机,以从文档表中选择 KPI,然后将结果插入结果表中。 What I need is, if the showed KPI's from the documentation table don't have any result in the results table it should be appeared in red color.我需要的是,如果文档表中显示的 KPI 在结果表中没有任何结果,它应该以红色显示。 Is it possible to do that??有可能这样做吗? Note: the primary key and the foreign key for the join between the tables is kpicode注意:表之间连接的主键和外键是kpicode

Here is a screenshot of the shuttle:这是班车的截图:

在此处输入图像描述

here is the SQL query for the shuttle to bring all the KPI's from the documentation table:这是 SQL 查询,用于从文档表中获取所有 KPI:

select distinct kpi as k1, kpicode as k2
from documentation
where kpi is not null;

The shuttle item does not allow you to provide html tags to style the options displayed in a shuttle.穿梭项目不允许您提供 html 标签来设置穿梭中显示的选项的样式。 You could write your own items or probably achieve your requirement with a modification to the template, but I'd like to propose a really simple way using jQuery.您可以编写自己的项目或通过修改模板来满足您的要求,但我想提出一种使用 jQuery 的非常简单的方法。

As you did not provide sample data, I am using the view user_tables and will try to highlight all the tables that include DEMO in their name with a red color, as soon as they are moved to the right side of the shuttle.由于您没有提供示例数据,我正在使用视图user_tables并将尝试用红色突出显示名称中包含DEMO的所有表,只要它们移动到航天飞机的右侧。

For my example, the source of the shuttle must provide some marking for the elements that need to be highlighted.对于我的示例,穿梭的来源必须为需要突出显示的元素提供一些标记。 If the table name contains DEMO , I prepend [red] :如果表名包含DEMO ,我会在前面加上[red]

select
    case when table_name like '%DEMO%' then '[red]' end || 
    table_name as d,
table_name as r
from user_tables
order by table_name

Now, the shuttle will look like this:现在,穿梭机将如下所示:

在此处输入图像描述

Now, add a short jQuery snippet to the Execute when Page Loads section of the page attributes:现在,将一个简短的 jQuery 片段添加到页面属性的Execute when Page Loads部分:

$('option:contains("[red]")').addClass("red").each(function() {
    $(this).html($(this).html().replace("[red]",""));
});

This will both add the CSS class red to the matched elements and remove the text [red] .这会将 CSS class red添加到匹配的元素并删除文本[red]

As a last step, use inline CSS to actually apply the styles:最后一步,使用内联 CSS 实际应用 styles:

.shuttle_right .red { color: red; font-weight: bold }

The filter .shuttle_right will make the red color only appear on the right side.过滤器.shuttle_right将使红色仅出现在右侧。 You can simply omit it if you want it to appear on both sides.如果你想让它出现在两边,你可以简单地省略它。

Now, the shuttle will look like this:现在,穿梭机将如下所示:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM