Need Column IDs to set style and calculations

In my table a have 6 columns as follows:

| Product | Qty. | Good | Damaged | Cut & Torn |

Qty.= Good + Damaged + Cut & Torn

normally for text box it will be done like:

 function sum() {
       var txtFirstNumberValue = document.getElementById('txt1').value;
       var txtSecondNumberValue = document.getElementById('txt2').value;
       if (txtFirstNumberValue == "")
           txtFirstNumberValue = 0;
       if (txtSecondNumberValue == "")
           txtSecondNumberValue = 0;

       var result = parseInt(txtFirstNumberValue) + parseInt(txtSecondNumberValue);
       if (!isNaN(result)) {
           document.getElementById('txt3').value = result;
       }
   } 

How it will be done with handsontable?
Thank you very much, any help will be appreciated

Hi @dassoubarna
I assume you’re suing Handsontable PRO. If so you can use formulas.
Here’s an example: http://jsfiddle.net/37jf19jx/2/

  • you need to have formulas: true in your settings
  • you need to add proper formula to a cell '=SUM(C2:E2)'

and the second question was about styling and it’s a really wide question.
If you would like to add styles for this particular column (with sum) you can for example add a class to a typed column:

cells: function(row, col){
    	var prop = {};
      if(col === 1){
      	prop.className = 'sum'
      };
      return prop;
    }

but if you would like to track some value (conditionals) I would need some more data to help.

Thanks a lot for the help.

you’re welcome @dassoubarna