gpt4 book ai didi

javascript - 更改动态 Oracle Apex 报告上的字段

转载 作者:行者123 更新时间:2023-12-01 08:38:59 26 4
gpt4 key购买 nike

这里既不是新手,也不是高级用户,
但是,
我对主要的客户端网络语言非常天真,现在我需要面对它。很快。
我有一个例子here - 用户:test 和密码test。我基于 here 中相同的 jquery 和 javascript 函数,由托尼·安德鲁斯先生回答。 在我的应用程序示例中,当 priority 字段更改时,它会放入 A 字段 的值(当它不为 0 或 null 时)。它只是将该字段中的结果相乘。
我试图在优先级字段更改时放置更改优先级脚本。例如:当将 id=1 的优先级更改为 1 时,id=2 的优先级必须更改为 3 -来自 id=1 的原始优先级。
我知道这是一个非常基本的算法,但我不知道如何在 apex 上的 javascript 或 jQuery 调用上及时做到这一点。我一直在尝试对报告进行更复杂的操作,但我需要首先了解基础知识。

为了澄清,我的查询报告和 JavaScript 执行是:

select distinct
apex_item.checkbox2(10,r.ID) ID,
apex_item.text(11,r.ID) ID_2,
apex_item.text(20,r.PRIORIDADE) PRIORITY,
apex_item.text(30,1) a,
apex_item.SELECT_LIST_FROM_LOV(31,r.PRIORIDADE,'LISTAPRIORIDADES',NULL,'NO') PRIORITY_LOV,
apex_item.text(40,null) b,


(select seq_id from apex_collections c where collection_name = 'COLECAO' AND c001 = r.id
)sequencial
from REPRIORIZA r



order by id;
//javascript execution, on dynamic action:

var target = apex.jQuery(this.triggeringElement).closest('tr').find('input[name="f30"]')
console.log(target)
var source = apex.jQuery(this.triggeringElement).closest('tr').find('input[name="f20"]')
console.log(source)
var result = target.val() * source.val();
target.val(result);
console.log(target)

var target2 = apex.jQuery(this.triggeringElement).closest('tr').find('input[name="f40"]')
console.log(target)
var source2 = apex.jQuery(this.triggeringElement).closest('tr').find('input[name="f11"]')
console.log(source2)
var result2 = source2.val();
target2.val(result2);

问候,

最佳答案

有几种方法可以做到这一点,我的建议如下:

1 - 在编写 apex_item 代码时,在选择中使用属性“p_attributes”和“p_item-id”,如下所示:

https://docs.oracle.com/cd/E14373_01/apirefs.32/e13369/apex_item.htm#AEAPI211

https://docs.oracle.com/cd/E14373_01/apirefs.32/e13369/apex_item.htm#AEAPI206

apex_item.text(
p_idx => 20,
p_value => 1,
p_attributes => 'data-id="' || CUSTOMER_ID || '"',
p_item_id => 'priority' || CUSTOMER_ID)
priority,
apex_item.text(
p_idx => 30,
p_value => 1,
p_attributes => 'data-id="' || CUSTOMER_ID || '"',
p_item_id => 'a' || CUSTOMER_ID)
a,
apex_item.SELECT_LIST_FROM_LOV(
p_idx => 31,
p_value => 1,
p_lov => 'LISTAPRIORIDADES',
p_attributes => 'data-id="' || CUSTOMER_ID || '"',
p_show_null => 'NO',
p_item_id => 'lov' || CUSTOMER_ID)
PRIORITY_LOV

执行此操作后,您可以轻松访问同一行中的每个项目。这些选择来 self 工作区中的示例表,请调整这些数据以适应您的表。

2 - 创建一个动态操作以在更改 lov 时触发,此动态操作应执行 JavaScript 代码。

enter image description here

3 - 在此 DA 的 javascript 代码中,您可以使用以下代码获取该行的每个元素:

var lineId = this.triggeringElement.getAttribute('data-id');
var lovItem = document.getElementById('lov' + lineId);
var aItem = document.getElementById('a' + lineId);
var priorityItem = document.getElementById('priority' + lineId);

enter image description here

现在您可以使用 lovItem、aItem 和priorityItem 字段执行所有操作。

4 - 在您的示例页面中,id 列是连续的,因此您只需增加 lineId 变量即可获取下一行,如下所示:

var nextLineId = lineId + 1;
var nextLovItem = document.getElementById('lov' + nextLineId);
var nextAItem = document.getElementById('a' + nextLineId);
var nextPriorityItem = document.getElementById('priority' + nextLineId);

*如果值不是连续的,也许您可​​以使用超前或滞后函数在“p_attributes”参数上的 apex_item 中再创建一个属性。 https://oracle-base.com/articles/misc/lag-lead-analytic-functions

关于javascript - 更改动态 Oracle Apex 报告上的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49845821/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com