2016-08-12 11 views
-1

私はOracle APEXを持っています。私は手作業で表形式を作成しました(apex_itemパッケージ)。 3つのフィールドがあります。oracle apexで動的アクションを表形式で使用するにはどうすればよいですか?

  • apex_application.g_f03:LOV(select name display, product_id return from products
  • apex_application.g_f04:テキストフィールドの "価格"
  • apex_application.g_f05:テキストフィールドの "数量"。

製品名(... f03)を選択した後、f04の製品の価格を確認したいと思います。 SQL文は次のようになります。

select price from products where product_id = {..from f03}. 

ダイナミックアクションまたはJavaScript関数を使用する方法は?

答えて

1

[OK]をクリックします。これで、シナリオの実装方法がわかります。あなたが必要とする

物事はそれを動作させるために、次のとおりです。

  • custom tabularをするために - あなたが既に持っていること
  • f03の値がを変更した場合に待機する
  • dynamic action
  • DBから製品の価格をfetchs
  • on demand process

オンデマンドプロセス

あなたはjQueryのセレクタ:input[name=f03]にイベントの変更を聞くために持っているコード

declare 
    v_price number; 
begin 
    select 
    price 
    into 
    v_price 
    from 
    products 
    where 
    product_id = apex_application.g_x01; 

    htp.p(v_price); 

exception 
    when others then 
    htp.p(SQLERRM); 
end; 

ダイナミックなアクション

以下でgetPriceという名前のオンデマンド・プロセスに作成します。真のアクションExecute JavaScript Codeで動的アクションを作成します。

実際のアクションでは、on demand processにajaxコールを送信する必要があります。サンプルコード(作業中)は次のとおりです。

var 
    xhr2, 
    self = $(this.triggeringElement), 
    productId = self.val(), 
    row = self.closest('tr'); 

xhr = $.ajax({ 
    url:'wwv_flow.show', 
    type:'post', 
    dataType: 'text', 
    traditional: true, 
    data: { 
    p_request: "APPLICATION_PROCESS=getPrice", 
    p_flow_id: $v('pFlowId'), 
    p_flow_step_id: $v('pFlowStepId'), 
    p_instance: $v('pInstance'), 
    //p_arg_names: [ item_id ], 
    //p_arg_values: [ itemValue ], 
    x01: productId 
    }, 

    success: function(resultData, textStatus, ajaxObj){ 
    //do stuff after fetching product price 
    row.find(':input[name=f04]').val(resultData) 

    }, 

    error: function(jqXHR, textStatus, errorThrown){ 
    alert('Error occured while retrieving AJAX data: '+textStatus+"\n"+errorThrown); 
    } 
}); 

あなたの質問に答えがあります。

ps。 あなたの質問に対する回答であれば、回答を役に立つとマークすることを忘れないでください。

関連する問題