ユーザーがボタン (たとえば、赤、緑、青のボタン) をクリックして、選択したセルに色を付けられるようにしたいと考えています。
選択したセルを取得するには、次のコードを見つけました。
$('div#example1').handsontable(options);
//get the instance using jQuery wrapper
var ht = $('#example1').handsontable('getInstance');
//Return index of the currently selected cells as an array [startRow, startCol, endRow, endCol]
var sel = ht.getSelected();
//'alert' the index of the starting row of the selection
alert(sel[0]);
しかし、ボタンをクリックしたときにこのコードを実行することはできません。これは、クリックした後、関数の実行が開始される前に選択が「消える」ためです。
この指示に従ってみますが、この問題の回避策が必要です。