1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    3
    Vote Rating
    0
    filosssof is on a distinguished road

      0  

    Default How can I calculate sum of elements (container html)?

    How can I calculate sum of elements (container html)?


    Hi! I have a big container (BC) which containts many containers (MC) and some buttons. MC also containts some numberfields, container with sum of these numberfields (SN) and some buttons which are coupled in another container. I need to calculate final sum of SN for each MC.

    A structure for the best understanding:
    Big Container (dish)
    _____________________________________________
    | MenuDish
    | ______________________________
    | | Ingredient (2 numberfields + container with sum in html)
    | |_________________
    | | Ingredient
    | |_________________
    | | Ingredient
    | |_________________
    | | Button
    | |_________________
    | | Button
    | |_________________
    | MenuDish
    | ______________________________
    | | Ingredient
    | |_________________
    | | Ingredient
    | |_________________
    | | Ingredient
    | |_________________
    | | Button
    | |_________________
    | | Button
    | |_________________
    |Button1
    |Button2
    Code:
    calculateTotalDish: function(numberfield){
                            var menuDish = numberfield.up("menudish");
                            menuDish.items.each(function(container){
                                if ((container.items != undefined)
                                        && (container
                                                .down('container[name=finalPrice]')))
                                console.log(container.down('container[name=finalPrice]'));
                            });
    This code is wired to change event of numberfield. In console I see the value of the first
    Life is good!

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,935
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Why not calculate the values from the store directly?

    Scott.

  3. #3
    Sencha Premium Member
    Join Date
    Aug 2011
    Location
    Hamburg - Germany
    Posts
    69
    Vote Rating
    1
    isaid is on a distinguished road

      0  

    Default how to calculate the values from the store directly

    how to calculate the values from the store directly


    can you give us an example how to calculate the values from the store directly?

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,935
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    You could calculate the fields at the table level using SQL, or you could perform it at the client level:
    http://jsfiddle.net/RMfzF/1/

    Scott.

  5. #5
    Sencha Premium Member
    Join Date
    Aug 2011
    Location
    Hamburg - Germany
    Posts
    69
    Vote Rating
    1
    isaid is on a distinguished road

      0  

    Default


    thank you Scot,
    i use architekt, so i aded a new field in the model num3 then a a convert function:
    var num1 = rec.get('num1')
    var num2 = rec.get('num2');
    return num1+num2;

    so num3 can calculate num1+num2
    perfect.
    greatings
    isaid

  6. #6
    Sencha User
    Join Date
    Jul 2012
    Posts
    1
    Vote Rating
    0
    okiter is on a distinguished road

      0  

    Default


    Fortunately, I also encountered this problem as you
    tu bep , stainless steel kitchen cabinets tu bep inox , bep dien tu Teka , may rua bat Teka