Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Completely disable a handsontable

I have just started using handsontable with JSON data and its working great but I need to disable all table input to certain users (read-only view).

Is there a way to completely disable a handsontable so none of the inputs respond and the remove row plugin doesn't function? I have tried http://dougestep.com/dme/jquery-disabler-widget-demos which doesn't seem to work and http://malsup.com/jquery/block/#element which works but it essentially creates an iframe overlay over the controls and with the removerow plugin the position is off set incorrectly.

like image 535
PeteT Avatar asked Mar 17 '14 11:03

PeteT


People also ask

How do I turn off Handsontable cell?

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.

What is Handsontable?

Handsontable is a data grid with spreadsheet features and look&feel. Handsontable is written in JavaScript and works with the most popular frameworks such as Angular, Vue and React. It can be easily modified or extended with custom plugins.


2 Answers

To fully "disable" a Handsontable I have done the following:

hot.updateSettings({
    readOnly: true, // make table cells read-only
    contextMenu: false, // disable context menu to change things
    disableVisualSelection: true, // prevent user from visually selecting
    manualColumnResize: false, // prevent dragging to resize columns
    manualRowResize: false, // prevent dragging to resize rows
    comments: false // prevent editing of comments
});
like image 123
JonBrave Avatar answered Sep 24 '22 03:09

JonBrave


You can do this using the updateSettings

var hot = $("#exampleGrid").handsontable('getInstance');
hot.updateSettings({
        readOnly: true
    });

Check the following link: http://jsfiddle.net/Hn3Zv/

like image 21
Mohamed ElHamamsy Avatar answered Sep 25 '22 03:09

Mohamed ElHamamsy