If you want to use values other than true and false, you have to provide this information using checkedTemplate and uncheckedTemplate. Handsontable will then update your data using the appropriate template.
import ReactDOM from'react-dom';import{ HotTable }from'@handsontable/react';import{ registerAllModules }from'handsontable/registry';import'handsontable/dist/handsontable.full.min.css';// register Handsontable's modulesregisterAllModules();constExampleComponent=()=>{return(<HotTabledata={[{car:'Mercedes A 160',year:2017,available:true,comesInBlack:'yes'},{car:'Citroen C4 Coupe',year:2018,available:false,comesInBlack:'yes'},{car:'Audi A4 Avant',year:2019,available:true,comesInBlack:'no'},{car:'Opel Astra',year:2020,available:false,comesInBlack:'yes'},{car:'BMW 320i Coupe',year:2021,available:false,comesInBlack:'no'}]}colHeaders={['Car model','Year of manufacture','Comes in black']}height="auto"columns={[{data:'car'},{data:'year',type:'numeric'},{data:'comesInBlack',type:'checkbox',checkedTemplate:'yes',uncheckedTemplate:'no'}]}licenseKey="non-commercial-and-evaluation"/>);};
ReactDOM.render(<ExampleComponent/>, document.getElementById('example2'));
Checkbox labels
To add a label to the checkbox, use the label option. You can declare where the label will be injected with this option - either before or after the checkbox element. You can also declare from which data source the label text will be updated.
import ReactDOM from'react-dom';import{ HotTable }from'@handsontable/react';import{ registerAllModules }from'handsontable/registry';import'handsontable/dist/handsontable.full.min.css';// register Handsontable's modulesregisterAllModules();constExampleComponent=()=>{return(<HotTabledata={[{car:'Mercedes A 160',year:2017,available:true,comesInBlack:'yes'},{car:'Citroen C4 Coupe',year:2018,available:false,comesInBlack:'yes'},{car:'Audi A4 Avant',year:2019,available:true,comesInBlack:'no'},{car:'Opel Astra',year:2020,available:false,comesInBlack:'yes'},{car:'BMW 320i Coupe',year:2021,available:false,comesInBlack:'no'}]}colHeaders={['Car model','Accepted','Comes in black']}height="auto"columns={[{data:'car'},{data:'available',type:'checkbox',label:{position:'after',property:'car'// Read value from row object},},{data:'comesInBlack',type:'checkbox',checkedTemplate:'yes',uncheckedTemplate:'no',label:{position:'before',value:'In black? '},},]}licenseKey="non-commercial-and-evaluation"/>);};
ReactDOM.render(<ExampleComponent/>, document.getElementById('example3'));