Search code examples
jqueryhandsontable

How to force a column of a Handson table jquery to be noneditable?


I have a 8 rows and two columns table. I need only the second column to be editable. The first column should be non editable (read only)

$(document).ready(function () {

  $("#example1").handsontable({
    startRows: 8,
    startCols: 2,
    rowHeaders: false,
    colHeaders: false,
    minSpareRows: 0,
    fillHandle: true
  });

Is there such an option in handsontable?


Solution

  • Handsontable allows you to specify a column that will be read only:

    $(document).ready(function () {
      $("#example1").handsontable({
        data: getCarData(),
        minSpareRows: 1,
        colHeaders: ["Car", "Year", "Chassis color", "Bumper color"],
        columns: [
          {
            data: "car",
            readOnly: true
          },
          {
            data: "year"
          },
          {
            data: "chassis"
          },
          {
            data: "bumper"
          }
        ]
      });
    });
    

    For more info, reference the handsontable docs.