Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Determine number of rows from javascript so I can hide if zero

Andrew TMay 14 2013 — edited May 15 2013
Hi All,

Found a great article which I adapted to use the link on a report to delete a row in db and remove from table (without a refresh).
It works great except I want the region to not display when there are no rows left.

Currently it shows "No Data Found" but because the page does not submit the region does not hide.

Here is the Java code:

function ackMsg(p_this, p_empno) {
// get the table row on which the user clicked
var tr = $(p_this).closest('tr');

// perform an asynchronous HTTP AJAX request using jQuery
$.ajax({
type: "POST",
url: "wwv_flow.show",
data: {
p_flow_id: $('#pFlowId').val(),
p_flow_step_id: $('#pFlowStepId').val(),
p_instance: $('#pInstance').val(),
x01: p_empno, // assign p_empno to the g_x01 global variable
p_request: "APPLICATION_PROCESS=ack_message" // refer to the application process
},
beforeSend: // executes while the AJAX call is being processed
function() {
// delete following HTML classes from the table row element
// could be possibly theme dependent
tr.removeClass('even');
tr.removeClass('odd');

// use jQuery's animate function to give the table row, and its children, a red background
tr.children().hover(function() {
tr.children().animate({'backgroundColor': '#00cc00'}, 300);
}, function() {
tr.children().animate({'backgroundColor': '#00cc00'}, 300);
});
tr.children().animate({'backgroundColor': '#00cc00'}, 300);
},
success: // to be called if the request succeeds
function() {
jQuery(p_this).trigger('apexrefresh');
// jQuery has difficulties animating inline elements
// that's why we wrap them in a div, which is a block element
tr.children().wrapInner('<div>').children().fadeOut(400, function() {
tr.remove(); // visually remove the row from the report
});
}
});
}

I did some Googling to add the line ' jQuery(p_this).trigger('apexrefresh');' which refreshes just that report.

What I think I need to do is add a check for number of rows left after the refresh then if = 0 do full page refresh to allow the region condition to hide it.

Unfortunately after hours on Google I can't find how to check how many rows are in the table.

PS the function is called from the link in the report like this onclick="ackMsg(this, #ACK#)"

Please help

AT

Edited by: user1678248 on May 13, 2013 9:39 PM

Edited by: user1678248 on May 13, 2013 9:40 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2013
Added on May 14 2013
4 comments
990 views