コンテキストメニューが実行する callback 関数の引数
key | contextmenu の items で定義したキー名称 |
selection | focusしているセルの開始から終わりまでの row と col |
clickEvent | マウスイベント |
console.log("start (" + selection[0].start.row+ ","+selection[0].start.col + ")" ); console.log("end (" + selection[0].end.row+ ","+selection[0].end.col + ")" );
で確認すればわかるが、selection がとても便利で、
Handsontable コンテキストメニューで、フォーカス選択した行の任意の列の値を
ページ遷移パラメータにすることができる。
グリッドを選択して、選択行の状況に沿った次のページを表示する場合など、
簡単にこれが使えるはずだ。
サンプル
var hot = new Handsontable(document.getElementById("table"), { data: Handsontable.helper.createSpreadsheetData(1000, 1000), width: '90%', height: 320, rowHeaders: true, colHeaders: true, contextMenu: { items:{ "goPage": { name: 'ページ遷移', callback: function(key, selection, clickEvent){ // 選択開始位置の行の2列目の値を遷移先ページパラメータにする var value = hot.getDataAtCell(selection[0].start.row, 1); location.href = './etcPage?param='+value; }, }, }, }, licenseKey: 'non-commercial-and-evaluation' });