【问题标题】:Changing fields on dynamic oracle apex report更改动态 oracle apex 报告上的字段
【发布时间】:2018-04-15 19:15:21
【问题描述】:

这里既不是新手也不是高级 apex 用户,
但是,
我对主要的客户端网络语言非常天真,现在我需要面对它。很快。
我有一个示例 here - 用户:test 和密码 test。 我基于来自here 的完全相同的 jquery 和 javascript 函数,由 Tony Andrews 先生回答。 在我的应用示例中,当 priority 字段发生更改时,它会放入 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);

问候,

【问题讨论】:

    标签: javascript jquery oracle-apex-5.1


    【解决方案1】:

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

    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
    

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

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

    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);
    

    现在您可以使用 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

    【讨论】:

    • 非常感谢,我得到了一位同事的帮助,在第 5 页上,我使用 dom 方法实现了优先级更改。您的贡献将有助于改进,尤其是在 lov 领域。
    【解决方案2】:

    嗯,

    对于这种情况,我问一个可能的答案是:

    var target = apex.jQuery(this.triggeringElement).closest('tr').find('input[name="f30"]')
    //console.log(target)
    var source = apex.jQuery(this.triggeringElement).find('input[name="f20"]')
    
    console.log(source)
    console.log('valor default: '.concat(source.context.defaultValue))
    //var lista  =  apex.jQuery(this.affectedElements[0].innerHTML).find('input[name="f20"]')
    var lista  =  apex.jQuery(source.context.form).find('input[name="f20"]')
    console.log('lista: '.concat(lista))
    for (var x=0;x<lista.length;x++){
        if (source.context.value == lista[x].value && source.context.defaultValue != lista[x].defaultValue){
            console.log(source)
            lista[x].value = source.context.defaultValue
            lista[x].defaultValue = source.context.defaultValue
            source.context.defaultValue = source.context.value
            console.log(lista[x])
        }
    }
    var colecao = apex.jQuery().find('input[name="f20"]')
    
    var result = target.val() * source.val();
    

    此代码将更改另一行中现有值之间的值。感谢之前的贡献!

    【讨论】:

    • 由于某种原因,代码变得毫无用处。在所选项目的上下文中返回错误。我相信这是由于 apex 18 的新版本造成的。
    • Apex 18 混淆了一些资源,如 context 和 context.form。例如,lista 变量现在设置为 var lista = apex.jQuery(source.prevObject[0].form).find('select[name="f13"]') 。正在努力……
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多