Samstag, 8. April 2017

Instant row deletion from Classic, Interactive Report or Tabular Form and show Custom Dialog to confirm the deletion

We will make it possible to remove a line from an interactive / Classic Or Tabular Form.
Let's start.

1-First Create your Report

2- Add the below Javascript in the Function and Global Variable Declaration
var gRecId;
function recordDelete ( recID) {
    gRecId = recID;
    $('a[href*="recordDelete('+recID +')"]').each(function(index) {
       $(this).parent()
              .parent('tr')
        .addClass('current');
    });
    setTimeout(processDeleteRecord, 50);
}
function processDeleteRecord(){
    rID = gRecId;
    var r = alertify.confirm("Do you want to really delete your Product ?", function (e) {
 
   
    console.log(new Date().getSeconds()+' confirm')
   if (e) {
        promiseDeleteRecord(rID)
            .then(function(data){
                console.log('record deleted');
                $('#IDP').trigger('apexrefresh');//Static ID for the Report
            }, displayError);
       alertify.success("Your Product is succefully delete");
    } else {
        $('a[href*="recordDelete('+rID +')"]').parent().parent('tr').removeClass('current');
    }
});
}
var displayError = function(error) {
    // $('#rError').removeAttr('style');
    $('#rError').show();
    $('.t-Alert-body', '#rError').html(error.responseText.replace(/sqlerrm:/,''));
};
var promiseDeleteRecord = function(param) {
    return apex.server.process(
        "DELETE_PROD", {
            x01: param
        }
    );
};
function hideError () {
    $('#rError').hide();
    $('tr.current', '#rFlfCompx').removeClass('current');
}


3- Create Your AJAX Callback Process  to delete Row in the Report
        The name of the Callback process is this case is DELETE_PROD.
         The Call-Back process is the PL/SQL code  below :
       
     begin
   delete from EMP  where empno=apex_application.g_x01;
    apex_json.open_object;
    apex_json.write('success', true);
    apex_json.write('recID', apex_application.g_x01);
    apex_json.close_object;
exception
    when others then
        apex_json.open_object;
        apex_json.write('success', false);
        apex_json.write('message', sqlerrm);
        apex_json.close_object
                          end;

4- Add the #APP_IMAGES#alertify.js in the Javascript Files Url of your page.
Note that you must dowload the Javascript-Plugin for the custom Jquery Dialog here

5- Select the row, the Type "Link" in the column to delete and add the Url like bellow:  javascript:recordDelete(#SAREG_ID_MELDEN#);

6-Explanation
"alertify.confirm"  is the custom dialog to be display. The Row will be deleted after the "Ok" Button is pressed

7-Live deletion of Row





Kommentare:

  1. Just now I have tried. It works. Thank You, Keep posting like this.

    AntwortenLöschen