Oracle APEX |逐行验证表格形式 [英] Oracle APEX | Validate Tabular form Row by Row

查看:108
本文介绍了Oracle APEX |逐行验证表格形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有表格形式来添加订单的订单明细,

I have tabular form to add order details for an order,

表格形式有 Popup LOV 自定义属性:

Tabular form has Popup LOV with this custom attribute:

onchange="javascript:do_cascade(this);"

这是最后一个函数的代码

here is the code of the last function

        function do_cascade(pThis)
    {

        var row_id=pThis.id.substr(4);
        apex.server.process("cascade_order_values", { x02: $(pThis).val()},
                           {type:"GET", dataType:"json", success:function(json)
                                                { 
                                                    var cond=0;
    // this var as flag changes to 1 when the new value found in tabular form.
                                                    var l_code=$(pThis).val();
    // to catch selected value to compare it with tabular form values
                                                    for (i =row_id;i>0;i=i-1)
    // this loop in order to check all tabluar form #f02_ column values
                                                        {
                                                           var id=('000'+i);//.slice(-4,0);
                                                           var curr_id='#f02_'+id;
                                                           var curr_code=$(curr_id).val();
                                                            if(curr_code==l_code)
                                                                {
                                                                    $('#f05_'+id).val('got it');
                                                                    $('#f05_'+id).focus();
                                                                   // i=0; cond=1;
                                                                } else cond=0;
                                                        }
                                                    if (cond==0) 
                                                    {
                                                        $('#f06_'+row_id).val(json.price);
                                                        $('#f04_'+row_id).val(json.pro_name);   
                                                    }
    else {
 // I want to write something here to delete the new added row
         }
                                                }
                             }
                           );
    }

最后一个函数即将执行的操作:当Popup LOV的选定值更改时函数调用应用程序进程查询并返回一些数据并将它们设置为表格形式字段,这样就可以正常执行。
这里是申请流程而不是此功能流程:

what the last function do shortly: when selected value change of the Popup LOV the function call application process to query and return some data and set them to the tabular form fields, and this perform correctly. here is the application process than this function process:

    declare
    price number;
    pro_code nvarchar2(20):=null;
    pro_name nvarchar2(50);

begin
    pro_code:=apex_application.g_x02;

    SELECT nvl(sell_price,0) into price from products where product_code=pro_code;

    SELECT C.CAT_NAME || ' - ' || U.UNIT_NAME into pro_name 
        FROM PRODUCTS P , CATEGORIES C, UNITS U
        WHERE P.CAT_ID=C.CAT_ID AND P.UNIT_ID=U.UNIT_ID AND P.PRODUCT_CODE=pro_code;

    sys.htp.p('{"price":"'||price||'", "pro_name":"'||pro_name||'","code":"'||pro_code||'"}');
EXCEPTION 
    WHEN others 
        THEN
            pro_name:='الرقم غير صحيح';
            sys.htp.p('{"price":"'||0||'", "pro_name":"'||pro_name||'","code":"'||pro_code||'"}');
end;

问题是:

我想检查所选产品代码是否以表格形式存在,这意味着从当前行到第一行逐行检查表格形式 所选值存在时,将焦点移动到项#f05 _ 并将值设置为
,然后删除当前的新行添加到表格形式

I want to check if the selected product code exist in the tabular form that mean check tabular form row by row from current row to the first one when the selected value exists move the focus to item #f05_ and set a value to it and then delete the new row that was added to the tabular form

我该怎么办呢。

帮助请!..

推荐答案

问题在于从表格形式中删除整行,

The problem is in deleting the whole row from tabular form,

所以用这段代码替换你的条件行:

so replace your conditional lines with this code:

if(curr_code==l_code) 
{ 
   $(pThis).val(''); 
   $('#f02_'+row_id).closest("tr").remove();
   $('#f05_'+id).val(parseInt($('#f05_'+id).val())+1); 
   $('#f05_'+id).focus(); i=0; cond=1; } 
else 
    cond=0;

这篇关于Oracle APEX |逐行验证表格形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆