Is there a proper way to get range string (e.g. B5:B13
) from coordinates (e.g. [4,1,4,12]
) in handsontable
?
I've tried to find one within official documentation, looked for an answer through 13 pages of handsontable
-tagged questions here, but found nothing. I thought it should be a rather popular issue, but it seems not:)
Thanks a lot!
Depends of your example, but if you let the colHeaders and rowHeaders to their default values (and setting them to true), you can do that easily in your afterSelectionEnd event.
See this JSFiddle that print in console the coordinate of the selected cell(s)
Getting the column name to construct your range string by using the headers :
hot.addHook('afterSelectionEnd', function(row1, col1, row2, col2) {
var
row1Header=hot.getRowHeader(row1),
col1Header=hot.getColHeader(col1),
row2Header=hot.getRowHeader(row2),
col2Header=hot.getColHeader(col2),
range=row1Header+col1Header+":"+row2Header+col2Header;
console.log(range);
});
After double checking there isn't any function that give you directly your expected result (range), but if you're interested in a more generic one (regardless the headers are present or not, above is just an example) you can let me know and I will try.