前提・実現したいこと
Handsontableを使用して全セルの値を一括で背景色設定、コメント削除を実施したいです。
以下のソースコードのように表の行数、列数を取得してループさせれば個別に出来るのですが、パフォーマンスが悪いので、パフォーマンスが改善されると思われるため、一括で処理させたいです。
実現方法を教えていただけないでしょうか。
該当のソースコード
JSX
1import React, { Component } from 'react'; 2import { HotTable } from '@handsontable/react'; 3import 'handsontable/dist/handsontable.full.css'; 4 5class Test extends Component { 6 constructor(props) { 7 super(props); 8 this.hotTableComponent = React.createRef(); 9 this.hotSettings = { 10 columns: [ 11 { title: 'test' } 12 ], 13 colWidths: [ 100 ], 14 startCols: 1, 15 startRows: 10, 16 rowHeaders: true, 17 width: 965, 18 height: 400, 19 }; 20 }; 21 createClick = () => { 22 // コメント 23 const commentsPlugin = this.hotTableComponent.current.hotInstance.getPlugin('comments'); 24 // 行数取得 25 const countRows = this.hotTableComponent.current.hotInstance.countRows(); 26 // 列数取得 27 const countCols = this.hotTableComponent.current.hotInstance.countCols(); 28 29 for (let intI = 0; intI < countRows; intI++) { 30 for (let intJ = 0; intJ < countCols; intJ++) { 31 // セル背景色初期化 32 this.hotTableComponent.current.hotInstance.setCellMeta( 33 intI, 34 intJ, 35 'className', 36 'err-style-release' 37 ); 38 // コメント削除 39 commentsPlugin.removeCommentAtCell(intI, intJ); 40 } 41 } 42 }; 43 render() { 44 return ( 45 <div> 46 <HotTable 47 id="hot" 48 ref={this.hotTableComponent} 49 settings={this.hotSettings} 50 /> 51 <button onClick={this.createClick}>登録</button> 52 </div> 53 ); 54 } 55}
補足情報(FW/ツールのバージョンなど)
"@handsontable/react": "^2.1.0",
"handsontable": "^6.2.2"
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。