公式不nghandsontable工作 [英] Formulas not working in nghandsontable
本文介绍了公式不nghandsontable工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的code是这个样子,还是我不能够计算总和值。任何一个可以帮助我解决this.I要添加在C柱的a和b的值。但我发现了如SUM(A1:B1)输出。
谁能电话我怎么解决这个问题?同样的code工作时使用Jquery做的罚款。<脚本SRC =handsontable.full.js类型=文/ JavaScript的>< / SCRIPT>
<链接HREF =handsontable.full.css的rel =stylesheet属性类型=文/ CSS>
<脚本SRC =angular.js类型=文/ JavaScript的>< / SCRIPT>
<脚本SRC =ngHandsontable.js类型=文/ JavaScript的>< / SCRIPT>
<脚本>
VAR应用= angular.module('对myApp',['ngHandsontable']);
app.controller('myCtrl',函数($范围){ $ scope.tabledata = {[答:'73903',B:'15015',C:= SUM(A1:B1)},
{A:'73904',B:'15013',C:= SUM(A2:B2)},
{A:'73905',B:'15014',C:= SUM(A3:B3)'}
];
$ scope.gridOptions = {
数据:资料表
};
$超时(函数(){
tableInstance.updateSettings({公式:真});
tableInstance.render();
},10);
});
< / SCRIPT>**在HTML code ** < DIV的风格=的位置是:相对的;数据-NG-控制器=myCtrl>
<热表
hotInstance =tableInstance
公式=真
colHeader =真
rowHeaders =假
文本菜单=假
数据行=资料表
colWidths =[100,100,100]>
<热列数据=A标题='A'>< /热柱>
<热列数据=b的称号=B>< /热柱>
<热列数据=C称号='总'>< /热柱>
< /热表>
< / DIV>
解决方案
您可以不是一个值直接引用一个对象在另一个值。这是可能的,但你需要调用的声明为C值的函数。
有一个更简单的形式给出将增加在资料表外的声明C:
为(VAR I = 0; I< tabledata.length;我++){
$ scope.tabledata [I] .C = $ scope.tabledata [I] .A + $ scope.tabledata [I] .B;
}
my code is look like this,still i am not able to calculate the sum value. Can any one help me to solve this.I want to add the values of a and b in C column. But I'm getting output as SUM(A1:B1).
Can anyone tel me how to solve this?The same code works fine in when done using Jquery.
<script src="handsontable.full.js" type="text/javascript"></script>
<link href="handsontable.full.css" rel="stylesheet" type="text/css">
<script src="angular.js" type="text/javascript"></script>
<script src="ngHandsontable.js" type="text/javascript"></script>
<script>
var app = angular.module('myApp', ['ngHandsontable']);
app.controller('myCtrl', function($scope) {
$scope.tabledata=[ {a:'73903', b:'15015', c:'=SUM(A1:B1)'},
{a:'73904', b:'15013', c:'=SUM(A2:B2)'},
{a:'73905', b:'15014', c:'=SUM(A3:B3)'}
];
$scope.gridOptions = {
data: 'tabledata'
};
$timeout(function(){
tableInstance.updateSettings({formulas: true});
tableInstance.render();
},10);
});
</script>
**THE HTML CODE**
<div style="position: relative;" data-ng-controller="myCtrl">
<hot-table
hotInstance="tableInstance"
formulas="true"
colHeader="true"
rowHeaders="false"
contextMenu="false"
datarows="tabledata"
colWidths="[100,100,100]">
<hot-column data="a" title="'A'" ></hot-column>
<hot-column data="b" title="'B'"></hot-column>
<hot-column data="c" title="'Total'"></hot-column>
</hot-table>
</div>
解决方案
You can't directly refer a value to another value inside an object. It is possible, but you need to invoke a function which you declare as a value of 'c'.
A more simple aproach will be adding 'c' outside the tabledata declaration:
for (var i = 0; i < tabledata.length; i++) {
$scope.tabledata[i].c = $scope.tabledata[i].a + $scope.tabledata[i].b;
}
这篇关于公式不nghandsontable工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文