【问题标题】:Oracle APEX | Validate Tabular form Row by Row甲骨文 APEX |逐行验证表格形式
【发布时间】:2016-09-19 10:58:54
【问题描述】:

我有表格形式来添加订单的详细信息,

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

onchange="javascript:do_cascade(this);"

这是最后一个函数的代码

        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的选择值改变时,函数调用应用程序来查询并返回一些数据并将它们设置到表格表单字段中,并且这会正确执行。 这里是比这个函数进程的应用进程:

    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;

问题是:

我想检查选定的产品代码是否存在于表格形式that mean check tabular form row by row from current row to the first one 选定的值存在时将焦点移动到项目#f05_ 并为其设置一个值 然后删除添加到表格形式的新行

请问我该怎么做。

请帮忙!..

【问题讨论】:

    标签: javascript jquery oracle-apex tabular-form


    【解决方案1】:

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

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

    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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-01
      • 1970-01-01
      相关资源
      最近更新 更多