Handsontable の再描画メソッドは、
インスタンスのメソッド render() で、できると思ってましたが、
うまくいかず再描画されません。
loadData( array )
を使うと再描画されます。
dataSchema を使うケース、、、
var hot = new Handsontable(document.getElementById("table"), { data: [], columns:[ { data: 'A', type: 'text' }, { data: 'B', type: 'numeric' }, { data: 'C', type: 'text' }, ], dataSchema: { A:null, B:null, C:null }, colHeaders: ["A", "B", "C" ], renderAllRows: true, copyPaste: true, autoColumnSize: true, licenseKey: 'non-commercial-and-evaluation', }); // クリックで任意のデータセットして再描画 $('#load').click(function(){ var a = new Array(); var m = {}; m['A'] = "Apple"; m['B'] = 24; m['C'] = "あいう"; a.push(m); hot.loadData(a); });
dataSchema を使わないケース、、、
var hot = new Handsontable(document.getElementById("table"), { data: [], columns:[ { type: 'text' }, { type: 'numeric' }, { type: 'text' }, ], colHeaders: ["A", "B", "C" ], renderAllRows: true, copyPaste: true, autoColumnSize: true, licenseKey: 'non-commercial-and-evaluation', }); // クリックで任意のデータセットして再描画 $('#load').click(function(){ var a = new Array(); var d = new Array(); d.push("Apple"); d.push(24); d.push("あいう"); a.push(d); hot.loadData(a); });