I want to do a something similar to http://handsontable.com/demo/prepopulate.html excepted that I want to pre-populate columns and not rows.
I undertstand that I have to use a function to define the default rendering. However, it only seems to work when adding rows but not colums : news rows are filled with "default" but not the columns.
This is what I tried :
function defaultValueRenderer(instance, td, row, col, prop, value, cellProperties) {
var args = $.extend(true, [], arguments);
if (args[5] === null) {
td.style.color = 'red';
args[5] = "default";
}
Handsontable.TextCell.renderer.apply(this, args);
}
var myData = [
["", "Kia", "Nissan", "Toyota", "Honda"],
["2008", 10, 11, 12, 13],
["2009", 20, 11, 14, 13],
["2010", 30, 15, 12, 13]
];
$("#exampleGrid").handsontable({
data: myData,
minSpareCols: 1,
minSpareRows: 1,
cells: function (row, col, prop) {
var cellProperties = {};
cellProperties.type = {renderer: defaultValueRenderer}
return cellProperties;
}
});
The defaultValueRenderer function seems not to be called when adding the spare columns (only for spare rows).
Thank your for your hints
EDIT : the value seems to be an empty string. I might use this as a workarround, however I believe I'm misunderstanding something here
As I got no reply, I'm answering my self. I hack arround using === null or === "". It works, it's ugly, still better than nothing ;)