我有类似的代码:
<script>
$(document).ready(function () {
var data = @Html.Raw(ViewBag.Data);
function sumPreviousValues(instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
td.val = 'SUM SEVERAL PREVIOUS CELLS';
}
container = document.getElementById('example1'),
settings1 = {
data: data,
colHeaders: @Html.Raw(ViewBag.TableHeader),
cells: function (row, col, prop) {
var cellProperties = {};
if (col == 16) {
cellProperties.renderer = sumPreviousValues;
}
return cellProperties;
}
},
hot = new Handsontable(container,settings1);
hot.render();
关键是修改功能sumPreviousValues()
但我不知道如何访问td
价值 ?如果可以访问其他单元格的值,例如td[index]
。
任何想法?我在文档中没有找到选项。
谢谢
我想我明白你想要做什么,这是一个简单的解决方案:
从自定义渲染器内部,您可以调用:
instance.getDataAtCell(row, col);
这将为您提供单元格的数据(值)row,col
。希望有帮助:)
另外,要访问当前 td 的值,您只需使用value
变量 :P 查看函数定义。您实际上是在传递它并且可供您使用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)