Disabled cells  Make specified cells read-only to protect them from unwanted changes but still allow navigation and copying of data.
 
  Overview  Disabling a cell makes the cell read-only or non-editable. Both have similar outcomes, with the following differences:
 Read-only cellreadOnly: true  Non-editable celleditor: false   Has an additional CSS class (htDimmed)  Has no additional CSS class   Copy works, paste doesn't work  Copy-paste works   Drag-to-fill doesn't work  Drag-to-fill works   Can't be changed by populateFromArray()  Can be changed by populateFromArray() 
  Read-only columns  In many use cases, you will need to configure a certain column to be read-only. This column will be available for keyboard navigation and copying data (Ctrl  /Cmd  +C  ). Editing and pasting data will be disabled.
 To make a column read-only, declare it in the columns  configuration option. You can also define a special renderer function that will dim the read-only values, providing a visual cue for the user that the cells are read-only.
 
 
  
  Read-only specific cells  This example makes cells that contain the word "Nissan" read-only. It forces all cells to be processed by the cells  function which will decide whether a cell's metadata should have the readOnly  property set.
 
 
     import { useRef, useEffect } from 'react';
import { HotTable } from '@handsontable/react';
import { registerAllModules } from 'handsontable/registry';
import 'handsontable/dist/handsontable.full.min.css';
// register Handsontable's modules
registerAllModules();
export const ExampleComponent = () => {
  const hotRef = useRef(null);
  useEffect(() => {
    const hot = hotRef.current.hotInstance;
    hot.updateSettings({
      cells(row, col) {
        const cellProperties = {};
        if (hot.getData()[row][col] === 'Nissan') {
          cellProperties.readOnly = true;
        }
        return cellProperties;
      }
    });
  });
  return (
    <HotTable
      ref={hotRef}
      data={[
        { car: 'Tesla', year: 2017, chassis: 'black', bumper: 'black' },
        { car: 'Nissan', year: 2018, chassis: 'blue', bumper: 'blue' },
        { car: 'Chrysler', year: 2019, chassis: 'yellow', bumper: 'black' },
        { car: 'Volvo', year: 2020, chassis: 'white', bumper: 'gray' }
      ]}
      colHeaders={['Car', 'Year', 'Chassis color', 'Bumper color']}
      height="auto"
      autoWrapRow={true}
      autoWrapCol={true}
      licenseKey="non-commercial-and-evaluation"
    />
  );
};
ReactDOM.render(<ExampleComponent />, document.getElementById('example2'));
  <script src="https://cdn.jsdelivr.net/npm/handsontable@14.1/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@14.1/dist/handsontable.full.min.css" /> 
<script src="https://cdn.jsdelivr.net/npm/react@17/umd/react.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/react-dom@17/umd/react-dom.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@handsontable/react@14.1/dist/react-handsontable.min.js"></script>
<script src="https://handsontable.com/docs/14.1/scripts/fixer.js"></script>
<div id="example2" class="hot "></div>
                
 Non-editable cells behave like any other cells apart from preventing you from manually changing their values.
  Non-editable columns  In many cases, you will need to configure a certain column to be non-editable. Doing this does not change its basic behaviour, apart from editing. This means that you can still use the keyboard navigation Ctrl  /Cmd  +C  , and Ctrl  /Cmd  +V   functionalities, and drag-to-fill, etc.
 To make a column non-editable, declare it in the columns  configuration option. You can also define a special renderer function that will dim the editor value. This will provide the user with a visual cue that the cell is non-editable.
 
 
     import { HotTable } from '@handsontable/react';
import { registerAllModules } from 'handsontable/registry';
import 'handsontable/dist/handsontable.full.min.css';
// register Handsontable's modules
registerAllModules();
export const ExampleComponent = () => {
  return (
    <HotTable
      data={[
        { car: 'Tesla', year: 2017, chassis: 'black', bumper: 'black' },
        { car: 'Nissan', year: 2018, chassis: 'blue', bumper: 'blue' },
        { car: 'Chrysler', year: 2019, chassis: 'yellow', bumper: 'black' },
        { car: 'Volvo', year: 2020, chassis: 'white', bumper: 'gray' }
      ]}
      height="auto"
      colHeaders={['Car', 'Year', 'Chassis color', 'Bumper color']}
      autoWrapRow={true}
      autoWrapCol={true}
      licenseKey="non-commercial-and-evaluation"
      columns={[
        {
          data: 'car',
          editor: false
        },
        {
          data: 'year',
          editor: 'numeric'
        },
        {
          data: 'chassis',
          editor: 'text'
        },
        {
          data: 'bumper',
          editor: 'text'
        }
      ]}
    />
  );
};
ReactDOM.render(<ExampleComponent />, document.getElementById('example3'));
  <script src="https://cdn.jsdelivr.net/npm/handsontable@14.1/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@14.1/dist/handsontable.full.min.css" /> 
<script src="https://cdn.jsdelivr.net/npm/react@17/umd/react.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/react-dom@17/umd/react-dom.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@handsontable/react@14.1/dist/react-handsontable.min.js"></script>
<script src="https://handsontable.com/docs/14.1/scripts/fixer.js"></script>
<div id="example3" class="hot "></div>
                
  Non-editable specific cells  The following example shows the table with non-editable cells containing the word "Nissan". This cell property is optional and you can easily set it in the Handsontable configuration.
 
 
     import { useRef, useEffect } from 'react';
import { HotTable } from '@handsontable/react';
import { registerAllModules } from 'handsontable/registry';
import 'handsontable/dist/handsontable.full.min.css';
// register Handsontable's modules
registerAllModules();
export const ExampleComponent = () => {
  const hotRef = useRef(null);
  useEffect(() => {
    const hot = hotRef.current.hotInstance;
    hot.updateSettings({
      cells(row, col, prop) {
        const cellProperties = {};
        if (hot.getDataAtRowProp(row, prop) === 'Nissan') {
          cellProperties.editor = false;
        } else {
          cellProperties.editor = 'text';
        }
        return cellProperties;
      }
    });
  });
  return (
    <HotTable
      ref={hotRef}
      data={[
        { car: 'Tesla', year: 2017, chassis: 'black', bumper: 'black' },
        { car: 'Nissan', year: 2018, chassis: 'blue', bumper: 'blue' },
        { car: 'Chrysler', year: 2019, chassis: 'yellow', bumper: 'black' },
        { car: 'Volvo', year: 2020, chassis: 'white', bumper: 'gray' }
      ]}
      colHeaders={['Car', 'Year', 'Chassis color', 'Bumper color']}
      height="auto"
      autoWrapRow={true}
      autoWrapCol={true}
      licenseKey="non-commercial-and-evaluation"
    />
  );
};
ReactDOM.render(<ExampleComponent />, document.getElementById('example4'));
  <script src="https://cdn.jsdelivr.net/npm/handsontable@14.1/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@14.1/dist/handsontable.full.min.css" /> 
<script src="https://cdn.jsdelivr.net/npm/react@17/umd/react.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/react-dom@17/umd/react-dom.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@handsontable/react@14.1/dist/react-handsontable.min.js"></script>
<script src="https://handsontable.com/docs/14.1/scripts/fixer.js"></script>
<div id="example4" class="hot "></div>
                
     Last update:  Nov 20, 2024