更改动态oracle顶点报告中的字段

时间:2018-04-15 19:15:22

标签: javascript jquery oracle-apex-5.1

此处也没有新手和先进的顶级用户,
但是,
 我对主要的客户端网络语言非常天真,现在我需要面对它。很快。
我有一个示例here - 用户:测试和密码测试。 我基于来自here的jquery和javascript函数,由Tony Andrews先生回答。  在我的应用示例中,当优先级字段发生更改时,它会将 A 字段的值设置为非0,也不为null。它简单地将该结果乘以该字段。
我正在尝试在更改时从优先级字段中添加更改优先级脚本。例如:何时将 id = 1 的优先级更改为1, id = 2 的优先级必须更改为 3 - 来自 id = 1 的原始优先级。我知道这是一个非常基本的算法,但我不知道如何及时,在javascript或jQuery调用apex上。我一直在尝试对报告进行更复杂的操作,但我需要先了解基础知识。

为了澄清我的查询报告和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);

此致

2 个答案:

答案 0 :(得分:1)

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

1 - 在编写apex_item代码时,在select中使用属性'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

执行此操作时,您可以轻松访问同一行中的每个项目。这些选择来自我工作区中的示例表,将这些数据调整到您的表中。

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

答案 1 :(得分:0)

那么,

对于我问的可能答案是:

getInt

此代码将更改另一行中存在的值之间的值。以前的贡献!