Sometime it's necessary to use tabular in oracle application express with ajax consedering new comer who wants to explorer more as they join in this article might help them to keep it going.
Steps to follow :
1) Create a tabular form based on table and save and run you're page you can see page is properly created and do not show any errors.
2) Now if you inspect you're tabular form checkbox (or cells) it will show name="f01"and Id = "f01_0001" just have a look at it for every cell you have on you're page.
3) Edit you're page and add Page Process(pl-sql) and target point will be Ajax callback lets add some pl/sql block in it
If you have observed properly we are sending some values from javascript code which is used as filter in where clause. Lets assume we wanted to show those data whose id = 100 then we are sending 100 from js (x01) and based on that ajax callback function fires and show data.
Debug Lets say we wanted to check what is going on under the hood !!!
Press f12 in chrome and click on network.
Now lets say we have select list on page we changed the value of select list and get the id of value we have just selected that id will be passed as x01 to ajaxcall back.
4) Lets took a look at javascript code :
//Tabular from will have on lov cell based on change of it ajaxcall will fire. also add onchang="get_item_details(pThis)" in lov's html attribute
function get_item_details(pThis){
var item_id = pThis.value;
var row_id = pThis.id.substr(4);
var my_id = $('#f02_'+row_id);
apex.server.process ("ajax_callback_process_name",
{
x01:my_id
},
{
type: 'GET',
dataType: 'json',
success: function(l_json_str)
{
$(apex_item).val(l_json_str.uom_id);
}
});
}
5) We need to make sure on which action we need to fire this action that is the most important thing to remember which is already shown above.
Declaimer
Oracle application express 5.0+
Javascript
Jquery
Oracle database 11g
Steps to follow :
1) Create a tabular form based on table and save and run you're page you can see page is properly created and do not show any errors.
2) Now if you inspect you're tabular form checkbox (or cells) it will show name="f01"and Id = "f01_0001" just have a look at it for every cell you have on you're page.
3) Edit you're page and add Page Process(pl-sql) and target point will be Ajax callback lets add some pl/sql block in it
declare l_id NUMBER; l_json_str varchar2(500); begin select id into l_id from my_table where columan = apex_application.g_x01;
--x01 is what we gonna send from js code on some event like click,change,onselect
and many more.... l_json_str := '{"id":"'||l_id||'"}'; sys.htp.p(l_json_str);
--press f12 network response
and you will see what is the response we are getting if there are some errors it will also show.
end;
Debug Lets say we wanted to check what is going on under the hood !!!
Press f12 in chrome and click on network.
Now lets say we have select list on page we changed the value of select list and get the id of value we have just selected that id will be passed as x01 to ajaxcall back.
4) Lets took a look at javascript code :
//Tabular from will have on lov cell based on change of it ajaxcall will fire. also add onchang="get_item_details(pThis)" in lov's html attribute
function get_item_details(pThis){
var item_id = pThis.value;
var row_id = pThis.id.substr(4);
var my_id = $('#f02_'+row_id);
apex.server.process ("ajax_callback_process_name",
{
x01:my_id
},
{
type: 'GET',
dataType: 'json',
success: function(l_json_str)
{
$(apex_item).val(l_json_str.uom_id);
}
});
}
5) We need to make sure on which action we need to fire this action that is the most important thing to remember which is already shown above.
Declaimer
Oracle application express 5.0+
Javascript
Jquery
Oracle database 11g