Hi,
We have an instance whereby we’d like to know if a column we are accessing has a particular ‘type’ or key/value pair assigned to it.
However, all we seem to be able to get is the column index - we can’t get the column settings that we provide in the columns: []
when creating a new Handsontable instance, nor can we find a function called getColumn
or similar.
var hot = new Handsontable(el, {
...
"columns":[
{"name":"Ident","data":"ident","type":"hbr-cell"},
{"name":"Title","data":"title","type":"hbr-truncated", "truncateLength":20},
]
...
);
Handsontable.cellTypes.registerCellType('hbr-truncated', {
renderer: function(instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.HtmlRenderer.apply(this, arguments);
if (instance.getDataAtCell(row, col).length > 30) {
td.innerHTML = '<div title="' + td.innerHTML + '">' + td.innerHTML.slice(0, 30) + '...</div>';
}
},
readOnly: true
});
(Where ‘30’ would be the truncateLength on the associated cells column)
In this instance (using a custom cell type with a custom renderer) we know the column index is 1
, we wish to use that information to determine what the truncateLength
is, so that in our renderer
we can truncate the length of the text accordingly.
If this isn’t possible, is there a way to provide our truncate length (or any other custom variable for that matter) per column? This data has to be passed through at the instantiation of the Handsontable.