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!

Invoke Action: selection-delete When Button Pressed and Update Accumulated Page Item

Dj SteeleSep 18 2018 — edited Oct 2 2018

Good Afternoon Community

I am using APEX 5.1.0.00.45  with Oracle 12c Database utilizing  PL/SQL Developer and SQL Developer

what I'm looking to Accomplish is Implement a Function that will tell when a Button has been clicked...Then  invoke an Action:  .invoke("Selection-Delete")...Then Call a Function that is at the Page level under Function and Global Variable Declaration  Which add up and sums a Column

that column being "Extended Price"

The Main Goal is to Delete Rows with  "Selection-Delete" and then run the Function at the Page Level to Update the Subtotal and Reflect the new Subtotal after a Row(s) have been Deleted

Here is the Code in the IG  Attributes Section that Configures the ToolBar:

function(config) {

    var $ = apex.jQuery,

        toolbarData = $.apex.interactiveGrid.copyDefaultToolbar(),

        lastToolbarGroup = toolbarData[4],

        deleteButton = {

                    type:     "BUTTON",

                    action:   "selection-delete",

                    hot:false,

                    icon:     "fa fa-minus",

                    label: "Delete Payment",

                    iconBeforeLabel: true,

                    labelkey: "DELETE_PAYMENT"

        };

    // Pop i.e remove the Save button, but pop still allow the Action, which we need to call

    //lastToolbarGroup.controls.pop(lastToolbarGroup.controls[1]);

    lastToolbarGroup.controls.push(deleteButton);

    config.toolbarData = toolbarData;

    config.initActions = function(actions) {

        actions.add([{

                name: "selection-delete",

                action: function(event, focusElement) {

                   var clicked = function () {

                        //if (document.getElementById('selection-delete').clicked == true)

                        if ($('selection-delete').clicked == true)

                            alert('button pushed');

                   apex.region('grdRcptLog').widget().interactiveGrid("getActions").invoke("selection-delete");

                       

                    }

                  

                    //function getRcptLogLines();                                         

                   

               

                    }

               

            }]

        );

    }

    return config;

}

Here is the JS  Code  ( a Function)  at the Page Level  that Adds  and  ( is Supposed to )  Recognize Deleted Rows

function getRcptLogLines() {

var model = apex.region("grdRcptLog").widget().interactiveGrid("getViews", "grid").model;

var EtotalKey = model.getFieldKey("EXTENDED_PRICE");

var totamt = 0;

  model.forEach(function(r) {

    //var eamt = parseFloat(r[EtotalKey], 10); //get rid of the base (10) argument it only applies to parseInt not parseFloat.

    

      var eamt = (r[EtotalKey]);

      //alert('before ' + eamt);

      var eamtnum = parseFloat(eamt.replace(/\,/g,''));

      recId = r[model.getFieldKey("LINE_ID")];

      isDeleted = model.getRecordMetadata(recId).deleted;

      if (typeof(isDeleted) == 'undefined') {

          isDeleted = false

      };

     

       if (!isNaN(eamtnum) && !(isDeleted)) {

       //alert('add inside if ' + payAmtnum); 

                   

        totamt += eamtnum;

        //  alert('After ' + payAmtnum);

        

       }

  });

console.log(">> setting sum EXTENDED_PRICE column to " + totamt)

$s('P64_SUBTOTAL',totamt);

}

Regards,

DSteele41

This post has been answered by Dj Steele on Oct 2 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 30 2018
Added on Sep 18 2018
2 comments
1,550 views