I have similar code:
<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();
The key is to modify the function sumPreviousValues()
But I dont know how to access the td
value ? and if it is possible to access other cells' value like td[index]
.
Any idea? I didn't find options in documentation.
Thank you
I have similar code:
<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();
The key is to modify the function sumPreviousValues()
But I dont know how to access the td
value ? and if it is possible to access other cells' value like td[index]
.
Any idea? I didn't find options in documentation.
Thank you
Share Improve this question edited Mar 13, 2015 at 17:04 bisko 4,0781 gold badge28 silver badges29 bronze badges asked Mar 13, 2015 at 16:33 MuflixMuflix 6,81619 gold badges96 silver badges173 bronze badges2 Answers
Reset to default 3I think I understand what you want to do and here is a simple solution:
From inside the custom renderer, you can call:
instance.getDataAtCell(row, col);
This will give you the data (value) of the cell at row,col
. Hope that helps :)
Also, to access the value at the current td, you just use the value
variable :P Look at the function definition. You are literally passing it in and is available to you.
To qualify this question, can you inspect the td
param being passed into sumPreviousValues()
. It would help to understand what this is, I would assume it's a HTML DOM node. If so, you could adjust it's value using td.innerHTML
More information on this can be found here: http://www.w3schools./jsref/prop_html_innerhtml.asp