Multiple Row Grand Total Calculation


 Step 1 :

Create Dynamic Action  

           Name : Calculate Grand Total

           Event : Lose Focus

           Selection Type : Region

           Region : (Select Grid Region)

True Action : Execute JavaScript Code

Code : 

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

var salKey = model.getFieldKey("QTY");

var commKey = model.getFieldKey("SALE_PRICE");

var subKey = model.getFieldKey("AMOUNT");

var totSAL = 0;

var totCOMM = 0;

var totSUB = 0;

model.forEach(function(r) {

    var sal = parseFloat(r[salKey], 10);

    var comm = parseFloat(r[commKey], 10);

    var sub = parseFloat(r[subKey], 10);

    if (!isNaN(sal)) {

        totSAL += sal;

    }

      if (!isNaN(comm)) {

        totCOMM += comm;

    }

      if (!isNaN(sub)) {

        totSUB += sub;

    }

});

$s('P100_QTY',totSAL);

$s('P100_SALE_PRICE',totCOMM);

$s('P100_AMOUNT',totSUB);


Create Again True Action - Set Value

                   Set Type - PL/SQL Expression

                   PL/SQL Expression - :SALE_PRICE

                   Items to Submit - SALE_PRICE

Affected Elements : 

                  Selection Type :  Items

                  Items : P100_SALE_PRICE


 Step 2 :

Select Grid Region And Write Static ID "igemp"





Post a Comment

Previous Post Next Post