Calculation for a cell with values from a cell from another table

时间:2015-07-13 21:14:20

标签: javascript handsontable

I am trying to recreate a excel like feel using HandsOnTable and RuleJS. I am able to put in formulas where the calculations use cell values from the same table but cannot find a way to compute with cells from different tables.

In my example(see http://jsfiddle.net/satyamallyaudipi/3sct2h8q/81/ , I have been trying to compute the value of a Addl Costs cell in lineItem1 Table from Customer $ Targets in "Target" Table as in =0.5*(B$2 from Target table)

Here is my html

<div id="target_Table" ></div>
<div id="lineItem_Table" ></div>

Here is the relevant javascript code

$(document).ready(function () {
  var targetContainer = document.getElementById('target_Table');    
  var lineItemContainer = document.getElementById('lineItem_Table'); 

  var targetData = [         
      ["","2016","2017","2018","2019","2020","2021","2022","2023","2024","2025","Total"], 
      ["Customer $ Targets:",500000,600000,700000,800000,900000,1000000,1100000,1200000,1300000,1400000,0],
      ["Customer % Targets:",0.55,0.56,0.57,0.58,0.58,0.59,0.59,0.60,0.6,0.6,0]];

   var lineItemData = [        
              ["","Total","2016","2017","2018","2019","2020","2021","2022","2023","2024","2025"],    
               ["Qty","=SUM(C2:L2)",1500,2400,3000,3000,2100,0,0,0,0,0],
               ["Addl Cost", "=0.005*B$2","=0.005*C$2", ="0.005*D$2", "=0.005*E$2",  "=0.005*F$2", "=0.005*G$2", "=0.005*H$2", "=0.005*I$2", "=0.005*J$2", "=0.005*K$2","=0.005*:L$2"]]; 
                                     ^-I would like this to be  targetData B column

      var target = new Handsontable(targetContainer, {
        data: targetData,
         ....
      });

    var lineItem1 = new Handsontable(lineItemContainer, {
        data: lineItemData,
         .....
      });

Here is the full jsfiddle http://jsfiddle.net/satyamallyaudipi/3sct2h8q/81/. Is it even possible to do this with HandsOnTable?

0 个答案:

没有答案
相关问题